Automated Flat Pattern Dimensions

Automated Flat Pattern Dimensions

lantinma
Enthusiast Enthusiast
5,681 Views
14 Replies
Message 1 of 15

Automated Flat Pattern Dimensions

lantinma
Enthusiast
Enthusiast

Hi All,

I have automated our sheet metal flat pattern dimensions to part iProperties. 

 

Function goes like this: 

Description: PL<Thickness> x <SHEET METAL WIDTH> x <SHEET METAL LENGTH>


Which looks like this:

Description: PL3,0 x 120,79 mm x 250,00 mm

 

I would like to set precision to 0,1mm and get rid of units (mm). With the "Thickness" parameter I don't have problem since it can be found from the parameters list but "Sheet metal width" and " Sheet metal length" are "hidden" sheet metal parameters and therefore I don't know how to change output.


Parameters list:

lantinma_0-1601446564249.png

 

-Leevi

0 Likes
Accepted solutions (3)
5,682 Views
14 Replies
Replies (14)
Message 2 of 15

WCrihfield
Mentor
Mentor

You can do this manually or by code:

Manually:

  • Select the Parameter's row within the Parameters dialog box
  • Click to put a check in the check box under the Export Parameter column.
    • That is what exposes the Parameter to the Custom iProperties
    • This only works manually for Numeric parameters at this time, but works for Text & True/False (Boolean) parameters when done by code.
  • Next right click on that row and choose "Custom Property Format..."
  • Within that Custom Property Format dialog box:
    • if the value is numeric, change the Property Type to Number, instead of Text
    • You'll notice that the options for "Units String", Leading Zeros", and "Trailing Zeros" are now greyed out, which means they don't apply to a truly numeric property.
    • Set the Untis and Precision where you want them
    • Then check box option called "Apply to existing comparable parameters" is useful to push these changes to all other similar parameters that are set to Export.
  • Then click OK on that dialog, and click Done on the Parameters dialog.
  • Now you should see all those parameters marked for "Export" within your Custom iProperties, and they should all show up correctly within your automated iProperty expressions.

If you want to know how to set all these things by code and how to set Text & Boolean type parameters to Export, , just let me know.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 15

lantinma
Enthusiast
Enthusiast

Hi,

 

Thanks for reply but the problem is that the parameters SHEET METAL WIDTH and SHEET METAL LENGTH cannot be found from the parameters list as you can see from the picture. These are  "hidden" parameters or something...

 

-Leevi

 

 

0 Likes
Message 4 of 15

WCrihfield
Mentor
Mentor

Actually, I don't thing the "Sheet Metal Width" & "Sheet Metal Length" are hidden sheet metal parameters.

They are actually standard (always there, whether they have values or not) iProperties, within the PropertySet named "Design Tracking Properties".  Property numbers 49 & 50, respectively (within that set).

Here's some simple iLogic code to access those iProperties.

 

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject And _
	ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value <> "Sheet Metal" Then
	MsgBox("This rule only works for Sheet Metal Part documents. Exiting.", vbOKOnly, " ")
	Exit Sub
End If

Dim oDTProps As PropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")

Dim oSMW As String = oDTProps.Item("Sheet Metal Width").Value
Dim oSML As String = oDTProps.Item("Sheet Metal Length").Value
Dim oSMA As String = oDTProps.Item("Sheet Metal Area").Value
MsgBox("Sheet Metal Width = " & oSMW & vbCrLf & _
"Sheet Metal Length = " & oSML & vbCrLf & _
"Sheet Metal Area = " & oSMA, vbOKOnly, "SHEET METAL SIZE")

Dim oFPW As String = oDTProps.Item("Flat Pattern Width").Value
Dim oFPL As String = oDTProps.Item("Flat Pattern Length").Value
Dim oFPA As String = oDTProps.Item("Flat Pattern Area").Value
MsgBox("Flat Pattern Width = " & oFPW & vbCrLf & _
"Flat Pattern Length = " & oFPL & vbCrLf & _
"Flat Pattern Area = " & oFPA, vbOKOnly, "FLAT PATTERN SIZE")

 

 

Edit:  Keep in mind the values returned are going to be in database default centimeters, and not in inches (or whatever units your document may be set to), so you may have to do some math or use a conversion tool within the code to return the units you want.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 15

JhoelForshav
Mentor
Mentor
Accepted solution

@lantinma 

How about this as a workaround:

Create two parameters in the document. ex. SM_Width, SM_Length.

Then have a rule like this trigger on "Part Geometry Change"

iLogicVb.UpdateWhenDone = True
SM_Width = SheetMetal.FlatExtentsWidth
SM_Length = SheetMetal.FlatExtentsLength

Export SM_Width and SM_Length to properties with the desired formatting settings and use those properties instead? 🙂

Message 6 of 15

WCrihfield
Mentor
Mentor

Building on @JhoelForshav 's idea to just create the parameters you want, based on those flat pattern size properties, so that you can better control how they will show up within your automated iProperty expressions, I put this iLogic code together as a means of automatically creating all three possible flat pattern size dimensions for you, then set up their formatting the way you want.  And all from an external iLogic rule, so you can reuse it on other similar sheet metal part documents.

Sub Main
	If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject And _
		ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value <> "Sheet Metal" Then
		MsgBox("This rule only works for Sheet Metal Part documents. Exiting.", vbOKOnly, " ")
		Exit Sub
	End If
	Dim oRParams As ReferenceParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.ReferenceParameters
	Dim oWidthP, oLengthP, oAreaP As ReferenceParameter
	Dim oW, oL, oA As Boolean

	For Each oRParam As ReferenceParameter In oRParams
		If oRParam.Name = "Flat_Pattern_Width" Then
			oWidthP = oRParam
			oWidthP.Value = SheetMetal.FlatExtentsWidth
			oW = True
		ElseIf oRParam.Name = "Flat_Pattern_Length" Then
			oLengthP = oRParam
			oLengthP.Value = SheetMetal.FlatExtentsLength
			oL = True
		ElseIf oRParam.Name = "Flat_Pattern_Area" Then
			oAreaP = oRParam
			oAreaP.Value = SheetMetal.FlatExtentsArea
			oA = True
		End If
	Next
	If oW = False Then oWidthP = oRParams.AddByValue(SheetMetal.FlatExtentsWidth, UnitsTypeEnum.kInchLengthUnits, "Flat_Pattern_Width")
	If oL = False Then oLengthP = oRParams.AddByValue(SheetMetal.FlatExtentsLength, UnitsTypeEnum.kInchLengthUnits, "Flat_Pattern_Length")
	If oA = False Then 	oAreaP = oRParams.AddByValue(SheetMetal.FlatExtentsArea, UnitsTypeEnum.kInchLengthUnits, "Flat_Pattern_Area")
	CPropFormat(oWidthP)
	CPropFormat(oLengthP)
	CPropFormat(oAreaP)
End Sub

Sub CPropFormat(ByRef oRefParam As ReferenceParameter)
	'Set the parameter itself's precision to 1 decimal place, if needed
	'oRefParam.Precision = 1
	If Not oRefParam.ExposedAsProperty Then oRefParam.ExposedAsProperty = True
	With oRefParam.CustomPropertyFormat
		.PropertyType = CustomPropertyTypeEnum.kNumberPropertyType
		.Precision = CustomPropertyPrecisionEnum.kOneDecimalPlacePrecision
	End With
End Sub

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 15

lantinma
Enthusiast
Enthusiast

Simple & classic, thanks. I had some issues with the updating but I made couple triggers to run rule.

Still I have problem with the precision, for some reason it ignores settings in parameters dialog (see picture)

 

My code:

iLogicVb.UpdateWhenDone = True

FlatPatternWidth = SheetMetal.FlatExtentsWidth
FlatPatternLength = SheetMetal.FlatExtentsLength

iProperties.Value("Project", "Description") = "PL" & Thickness & "X" & FlatPatternLength & "X" & FlatPatternWidth

lantinma_0-1601546257875.png

 

Message 8 of 15

lantinma
Enthusiast
Enthusiast

Thanks for the code, it worked but I prefer to have simpler solution (@JhoelForshav way) - easier everybody to understand & maintain.

0 Likes
Message 9 of 15

JhoelForshav
Mentor
Mentor

Hi @lantinma

The code you posted just now does not use the properties, but the parameters. So the proerty formatting will have no effect on that.

Using the parameters isn't such a bad idea though, see rule below 🙂

 

I use .ToString to format the values to one decimal.

iLogicVb.UpdateWhenDone = True

FlatPatternWidth = SheetMetal.FlatExtentsWidth
FlatPatternLength = SheetMetal.FlatExtentsLength

RuleParametersOutput()

Dim length As Double = FlatPatternLength
Dim width As Double = FlatPatternWidth
Dim T As Double = Thickness
iProperties.Value("Project", "Description") = "PL" & T.ToString("0.0") & "X" & length.ToString("0.0") & "X" & width.ToString("0.0")

 

Message 10 of 15

WCrihfield
Mentor
Mentor
Accepted solution

The Custom Property Format only effects how the value will look in the iProperties.

There are other ways to make the actual parameter also be rounded to 1 decimal place.

Here's the simplest way:

FlatPatternWidth = Round(SheetMetal.FlatExtentsWidth, 1)
FlatPatternLength = Round(SheetMetal.FlatExtentsLength, 1)

This simply rounds the value of "SheetMetal.FlatExtentsWidth" to 1 decimal place, before adding it at the value of the specified parameter.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 15

JhoelForshav
Mentor
Mentor
Accepted solution

@WCrihfield 

The reason I suggested to format the values with .ToString is because I was under the impression that @lantinma always wanted to display one decimal. If you use round for a value = 3 for example it'll return 3, not 3,0. The rule I suggested was a bit overkill though. Better to just not create the parameters for width and length if we don't intend to export properties from them 🙂

 

iLogicVb.UpdateWhenDone = True
Dim T As Double = Thickness
iProperties.Value("Project", "Description") = "PL" & T.ToString("0.0") & "X" & SheetMetal.FlatExtentsLength.ToString("0.0") & "X" & SheetMetal.FlatExtentsWidth.ToString("0.0")

 

Message 12 of 15

lantinma
Enthusiast
Enthusiast

Thanks @WCrihfield and @JhoelForshav for quick solutions!

 
Message 13 of 15

DeerSpotter
Collaborator
Collaborator

Why is your code making the thickness and dimensions come in as mm instead of what the document dimensions are?

In my case as: in

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
0 Likes
Message 14 of 15

JhoelForshav
Mentor
Mentor

Hi @DeerSpotter 

When I try it myself in a document with length units = in, SheetMetal.FlatExtentsLength and SheetMetal.FlatExtentsWidth are both returned in the documents length units...

 

Are you sure the length units of the document is set to "inch"?

inch.PNG

If so, maybe try this rule instead. In general I find API-functions more robust than iLogic-functions. These will always return the value in database units (cm for length). From there we can use units of measure to convert to the documents length units:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oDef.HasFlatPattern = False
	oDef.Unfold
	oDef.FlatPattern.ExitEdit
End If
Dim UoM As UnitsOfMeasure = oDoc.UnitsOfMeasure
'Convert from Database length units to length units of document
Dim oLength As Double = UoM.ConvertUnits(oDef.FlatPattern.Length, UnitsTypeEnum.kDatabaseLengthUnits, UoM.LengthUnits)
Dim oWidth As Double = UoM.ConvertUnits(oDef.FlatPattern.Width, UnitsTypeEnum.kDatabaseLengthUnits, UoM.LengthUnits)
Dim T As Double = UoM.ConvertUnits(oDef.Thickness.Value, UnitsTypeEnum.kDatabaseLengthUnits, UoM.LengthUnits)
'Set the Description property
iProperties.Value("Project", "Description") = "PL " & T.ToString("0.0") & " X " & oLength.ToString("0.0") & " X " & oWidth.ToString("0.0")
Message 15 of 15

WCrihfield
Mentor
Mentor

Hi @DeerSpotter.

When using the SheetMetal.FlatExtents... property call directly, I receive results in document units.  This is my test for that.  Start from your Flat Pattern being active on your screen, then use your manual measure tool to inspect the top main flat face of the part.  When I measure width & length (along X & Y axis), and measure area, the dialog shows these in document units, so I know what they are supposed to be.  Then I run this rule to see the result returned by those iLogic property calls.

Dim oSMW As Double = SheetMetal.FlatExtentsWidth
Dim oSML As Double = SheetMetal.FlatExtentsLength
Dim oSMA As Double = SheetMetal.FlatExtentsArea
MsgBox("Sheet Metal Width = " & oSMW.ToString("0.0") & vbCrLf & _
"Sheet Metal Length = " & oSML.ToString("0.0") & vbCrLf & _
"Sheet Metal Area = " & oSMA.ToString("0.0"), vbOKOnly, "SHEET METAL SIZE")

 That is just one way of getting those numbers.  However, there is also two sets of regular iProperties that you can check the values of.  These other 'regular' iProperties are zero by default though, until you have done something like calculating physical properties or have generated a flat pattern previously.  Here is an iLogic rule for checking these other sheet metal size properties.

oDoc = ThisDoc.Document
If TypeOf oDoc Is PartDocument And
	TypeOf oDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
	Dim oDTProps As PropertySet = oDoc.PropertySets.Item(3)

	Dim oSMW As String = oDTProps.Item("Sheet Metal Width").Value
	Dim oSML As String = oDTProps.Item("Sheet Metal Length").Value
	Dim oSMA As String = oDTProps.Item("Sheet Metal Area").Value
	MsgBox("Sheet Metal Width = " & oSMW & vbCrLf & _
	"Sheet Metal Length = " & oSML & vbCrLf & _
	"Sheet Metal Area = " & oSMA, vbOKOnly, "SHEET METAL SIZE")

	Dim oFPW As String = oDTProps.Item("Flat Pattern Width").Value
	Dim oFPL As String = oDTProps.Item("Flat Pattern Length").Value
	Dim oFPA As String = oDTProps.Item("Flat Pattern Area").Value
	MsgBox("Flat Pattern Width = " & oFPW & vbCrLf & _
	"Flat Pattern Length = " & oFPL & vbCrLf & _
	"Flat Pattern Area = " & oFPA, vbOKOnly, "FLAT PATTERN SIZE")
End If

You will notice that the 'Sheet Metal' iProperties here return document units, while the 'Flat Pattern' iProperties here return default metric units (centimeters & centimeters squared).

There is a built-in tool for converting units that you could use (oDoc.UnitsOfMeasure.ConvertUnits()), or you could just include some simple math to convert the units.

 

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes