Here is the example I use at the part level, just to test what it returns at,
Dim extents_length As Double
Dim extents_width As Double
extents_length = SheetMetal.FlatExtentsLength
extents_width = SheetMetal.FlatExtentsWidth
MessageBox.Show(extents_length)
MessageBox.Show(extents_width)
This returns the correct value.
This is the code that I use at the assembly level (with multiple sheet metal parts).
Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
Dim FNamePos As Integer = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String = Right(docFile.FullFileName, Len(docFile.FullFileName) -FNamePos)
Dim docPNum As String = iProperties.Value(docFName, "Project", "Part Number")
If iProperties.Value(docFName, "Project", "Part Number") = "AL03060" Then
MessageBox.Show("Did I Make it?")
' Checks to see if the active document is a standard part.
If docFile.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}"
' If it is a standard part it is converted to sheet metal
Try
docFile.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
Catch
' Catch error and exit rule when part can't be converted
' Example: multiple solid body part
Return
End Try
End If
MessageBox.Show(docFile.SubType)
' Gets the document's units of measure
Dim uom As UnitsOfMeasure = docFile.UnitsOfMeasure
' Converts length unit to a string
Dim Units As String = uom.GetStringFromType(uom.LengthUnits)
' Gets the X & Y dimensions of the part from sheetmetal extents
X = SheetMetal.FlatExtentsLength
Y = SheetMetal.FlatExtentsWidth
MessageBox.Show(X)
MessageBox.Show(Y)
' Go to the FlatPattern
Dim oSMCD As SheetMetalComponentDefinition
oSMCD = docFile.ComponentDefinition
' Look for Flatpattern
If Not oSMCD.HasFlatPattern Then
' Create Flatpattern if the part doesn't have one
oSMCD.Unfold()
docFile.Update2(True)
Else
oSMCD.FlatPattern.Edit
End If
' Get the min and max point of the Flatpattern
Dim minPoint As Point = oSMCD.SurfaceBodies.Item(1).RangeBox.MinPoint
Dim maxPoint As Point = oSMCD.SurfaceBodies.Item(1).RangeBox.MaxPoint
' Tickness is maxPoin - minPoint
' Since FlatPattern always returns "cm", we have to multiple it by 10 to get "mm"
Z = (maxPoint.Z - minPoint.Z) * 10
' Create measure strings
Dim LengthString As String = MaxOfMany (X,Y,Z)
Dim WidthString As String = X + Y + Z - MaxOfMany (X,Y,Z) - MinOfMany(X,Y,Z)
Dim ThicknessString As String = MinOfMany (X,Y,Z)
' Sets iProperties for Length, Width & Thickness. Unit string is added to each value.
MessageBox.Show(LengthString)
MessageBox.Show(WidthString)
MessageBox.Show(ThicknessString)
' Exit the FlatPattern
oSMCD.FlatPattern.ExitEdit()
Else
End If
Next
This returns zero in my message boxes for X and Y.
Any help would be greatly appreciate.
Thanks,
AT