Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: iLimbani

I am not sure how those standard sheet metal length and width specs are figured/obtained behind the scenes, but there is another option that might possibly result in more accurate or conservative values, if odd orientations is an issue.  It would require a bit of Inventor API code to access, but may be worth it, if it works better for you.  The FlatPattern API object has a direct property (FlatPattern.OrientedMinimumRangeBox) which is supposed to ignore the model's X, Y, & Z orientation with respect to the model's origin, to get true minimum size in any orientation.  That property returns an OrientedBox API object.  We can get the 3 directional lengths from that object using the following process.  Its DirectionOne, DirectionTwo, and DirectionThree properties return a Vector API object.  That Vector has a Length property, which we can get that measurement from.  However, that measurement will be in 'database units' (always centimeters, for distance/length), instead of 'document units', so some units conversion may be needed to get the results in something other than centimeters units.

 

Here is an example iLogic rule using this technique, but just shows the resulting size in a message.  Those values could also be written to iProperties or Parameters.

Sub Main
	If ThisDoc.Document.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Return
	Dim oPDoc As PartDocument = ThisDoc.Document
	Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim oFP As FlatPattern = Nothing
	If oSMDef.HasFlatPattern Then
		oFP = oSMDef.FlatPattern
	Else
		Try
			oSMDef.Unfold()
			oFP = oSMDef.FlatPattern
			oFP.ExitEdit
		Catch
			Logger.Error("Error unfolding Sheet Metal part to get FlatPattern.")
		End Try
	End If
	If oFP Is Nothing Then Return
	Dim oBox As OrientedBox = oFP.OrientedMinimumRangeBox
	Dim oList As New List(Of Double)
	'convert centimeter units to document units, then round the value off to 3 decimal places
	oList.Add(Round(oPDoc.UnitsOfMeasure.ConvertUnits(oBox.DirectionOne.Length, "cm", oPDoc.UnitsOfMeasure.LengthUnits), 3))
	oList.Add(Round(oPDoc.UnitsOfMeasure.ConvertUnits(oBox.DirectionTwo.Length, "cm", oPDoc.UnitsOfMeasure.LengthUnits), 3))
	oList.Add(Round(oPDoc.UnitsOfMeasure.ConvertUnits(oBox.DirectionThree.Length, "cm", oPDoc.UnitsOfMeasure.LengthUnits), 3))
	oList.Sort()
	MsgBox("FlatPattern Min Size = " & oList(0).ToString & " x " & oList(1).ToString & " x " & oList(2).ToString, vbInformation, "FlatPattern Size")
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)