troubles getting a correct bounding box measure

Hi all,

I have a function which gets the dimension of the bounding box for a sheet metal part. It works fine, or I thought that .... but I have found something quite disturbing.

I came across this part which has a bounding box of 673x198 mm. but when I get the dimensions through the function, it gives me 663x196 mm. And I don't know why, I can't figure out where those dimensions are coming from. I have tried two different ways of getting the dimensions and it is the same.

I discovered that the function gives me the correct bounding box if I flatten manually the part before running the code. But it doesn't work if I flatten the part on the code.

Any idea of what is happening here? I am getting crazy!

Please, could someone give a hint? Thank you for sharing your knowledge.

Cheers,

Rafa

This is the code of the part where I get the dimensions

When I find the bounding-box on the features tree ....

One way of getting the bounding-box:

If InStr(1, swChildFeature.Name, "Bounding-Box") > 0 Then

Set swSketch = swChildFeature.GetSpecificFeature

vSketchSeg = swSketch.GetSketchSegments

For i = 0 To UBound(vSketchSeg)

Set swSketchSeg = vSketchSeg(i)

Length = Length + swSketchSeg.GetLength

xy = swSketchSeg.GetLength

Next i

Length = Length * 1000

xy = xy * 1000

If (Length / 2) - xy >= xy Then

X = (Length / 2) - xy

Y = xy

Else

Y = (Length / 2) - xy

X = xy

End If

If X - Round(X, 0) > 0.01 Then

X = Int(Math.Round(X, 2)) + 1

Else

X = Int(Math.Round(X, 2))

End If

If Y - Round(Y, 0) > 0.01 Then

Y = Int(Math.Round(Y, 2)) + 1

Else

Y = Int(Math.Round(Y, 2))

End If

GetSheetMetalBoundingBox_TraverseNode2 = CStr(X) & ":" & CStr(Y) & " - " & CStr(X2) & ":" & CStr(Y2)

Exit Function

End If

:

Another way of getting the bounding-box:

If InStr(1, swChildFeature.Name, "Bounding-Box") > 0 Then

boolstatusflat = swModel.SetBendState(swSMBendStateFlattened)

boolstatus = swModel.ForceRebuild3(False)

boolstatus = swChildFeature.GetBox(BoxFeatureArray)

Measure1 = (Abs(BoxFeatureArray(0)) + Abs(BoxFeatureArray(3))) * 1000

Measure2 = (Abs(BoxFeatureArray(1)) + Abs(BoxFeatureArray(4))) * 1000

Measure3 = (Abs(BoxFeatureArray(2)) + Abs(BoxFeatureArray(5))) * 1000

boolstatus = swModel.SetBendState(swSMBendStateFolded)

swModel.EditRebuild3

If Measure1 = 0 Then

If Measure2 >= Measure3 Then

X2 = Measure2

Y2 = Measure3

Else

X2 = Measure3

Y2 = Measure2

End If

ElseIf Measure2 = 0 Then

If Measure1 >= Measure3 Then

X2 = Measure1

Y2 = Measure3

Else

X2 = Measure3

Y2 = Measure1

End If

ElseIf Measure3 = 0 Then

If Measure1 >= Measure2 Then

X2 = Measure1

Y2 = Measure2

Else

X2 = Measure2

Y2 = Measure1

End If

End If

If X2 - Round(X2, 0) > 0.01 Then

X2 = Int(Math.Round(X2, 2)) + 1

Else

X2 = Int(Math.Round(X2, 2))

End If

If Y2 - Round(Y2, 0) > 0.01 Then

Y2 = Int(Math.Round(Y2, 2)) + 1

Else

Y2 = Int(Math.Round(Y2, 2))

End If

GetSheetMetalBoundingBox_TraverseNode2 = CStr(X) & ":" & CStr(Y) & " - " & CStr(X2) & ":" & CStr(Y2)

Exit Function

End If

SolidworksApi/macros