Hi Everyone,
Hopefully this thread will be useful to others looking for help as they can use what I have gathered so far. I am using iLogic rules in Inventor 2012 to create, format and export parameters and create a description in the iProperties of the part. This is then updated in the material list in the idw. Some of them work great, but I'm now needing help on creating a parameter which will equal the "flat pattern width" of a rolled piece of flat plate. Then the parameter that has been created will then format according to the iLogic code , then be exported for use in the material list. I basically want a fully automatic material list in the drawing. So what I have now:
[Before we start, a huge thanks goes out to Curtis_Waguespack - I used a lot of his information I found dotted around the forum, what a guy!]
If you have a square plate and want the Width, Length & Thickness given, go into your part and rename the appropriate dimensions/extrusions to suit the Width/Length/THK. Then run this code:
Dim oWidth, oLength, oTHK As Parameter
Dim oFormat As CustomPropertyFormat
oWidth = Parameter.Param("Width")
oWidth.ExposedAsProperty = True
oFormat=oWidth.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oLength = Parameter.Param("Length")
oLength.ExposedAsProperty = True
oFormat=oLength.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oTHK = Parameter.Param("THK")
oTHK.ExposedAsProperty = True
oFormat=oTHK.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
iProperties.Value("Project", "Description") = "=<Width> x <Length> x <THK> Thk Plate"
If you want a round plate to be exported to the material list, rename the outside diameter parameter to "OD" and your thickness parameter to "THK" and then run this code:
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oParameter=oMyParameter.AddByExpression("Length", "OD", UnitsTypeEnum.kMillimeterLengthUnits)
oParameter=oMyParameter.AddByExpression("Width", "OD", "mm")
Dim oOD, oID, oTHK As Parameter
Dim oFormat As CustomPropertyFormat
oOD = Parameter.Param("OD")
oOD.ExposedAsProperty = True
oFormat=oOD.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oID = Parameter.Param("ID")
oID.ExposedAsProperty = True
oFormat=oID.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oTHK = Parameter.Param("THK")
oTHK.ExposedAsProperty = True
oFormat=oTHK.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
iProperties.Value("Project", "Description") = "=<OD> O/D x <ID> I/D x <THK> Thk Round Plate"
If you have tube, set the OD & ID by renaming the relevant parameters, and also change the parameter controlling the length to "Length" and run the following code:
Dim oOD, oID, oLength As Parameter
Dim oFormat As CustomPropertyFormat
oOD = Parameter.Param("OD")
oOD.ExposedAsProperty = True
oFormat=oOD.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oID = Parameter.Param("ID")
oID.ExposedAsProperty = True
oFormat=oID.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oLength = Parameter.Param("Length")
oLength.ExposedAsProperty = True
oFormat=oLength.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
iProperties.Value("Project", "Description") = "=<OD> O/D x <ID> I/D x <Length> Lg Tube"
Now i'm struggling on my "Rolled Flat" code. Basically I want something of an example OD (say 1500 diameter) but it is to be rolled out of 50mm wide x 4mm thick steel. I use sheet metal for this, and create a sketch with a circle that has a 2mm split in, so it can be flat patterned. I want the flat pattern developed width to be referenced in the material list. My best attempt doesn't work, but I'll show you what I've tried - (IT'S BROKEN SO DON'T USE):
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oParameter=oMyParameter.AddByExpression("Length", "Flat Pattern Width", UnitsTypeEnum.kMillimeterLengthUnits)
Dim oOD, oTHK, oLength, oWidth As Parameter
Dim oFormat As CustomPropertyFormat
oOD = Parameter.Param("OD")
oOD.ExposedAsProperty = True
oFormat=oOD.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oTHK = Parameter.Param("THK")
oTHK.ExposedAsProperty = True
oFormat=oTHK.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oLength = Parameter.Param("Length")
oLength.ExposedAsProperty = True
oFormat=oLength.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oWidth = Parameter.Param("Width")
oWidth.ExposedAsProperty = True
oFormat=oWidth.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
iProperties.Value("Project", "Description") = "=<Width> x <THK> Thk Plate ~ Rolled to <OD> O/D"
If you found any of this useful I would appreciate any kudos you can give. I've been helped so much by this forum and really want to help and give back something.
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
Why don't you just use the flat pattern extents method?
Here is a snippet of my sheet metal rule:
If oSheetMetalCompDef.HasFlatPattern = True Then Parameter("lengthExtents") = SheetMetal.FlatExtentsWidth Parameter("widthExtents") = SheetMetal.FlatExtentsLength End If
Hi Mike,
Thanks for the reply, however it doesn't work, as below:
"Rule Compile Errors in 005 - Flat Rolled, in F-010-00-F-008-004.ipt
Error on Line 1 : Name 'oSheetMetalCompDef' is not declared."
Is there not a way to make "Length" = (whatever the flat pattern developed width parameter is called) - and then I know what to do after that. I think...
Sorry, I left this out:
Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = ThisDoc.Document.componentdefinition
So the snippet is:
Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = ThisDoc.Document.ComponentDefinition If oSheetMetalCompDef.HasFlatPattern = True Then Parameter("lengthExtents") = SheetMetal.FlatExtentsWidth Parameter("widthExtents") = SheetMetal.FlatExtentsLength End If
Of course, if you don't want the error check for a flat pattern then you can simply use:
Parameter("lengthExtents") = SheetMetal.FlatExtentsWidth Parameter("widthExtents") = SheetMetal.FlatExtentsLength
Cheers Mike!
It works on it's own, but when I put the other bit behind it (that I have for formatting and exporting the properties) it won't work. Is there a way to make the script happily do both at the same time?
Got it! I had to rearrange the part of the script that runs the rule to add "Length" to parameters. Cheers Mike you're a star!
The only problem I have now is whenever I run the rule it will make "Length_1" and "Length_2" etc. etc....
Hehe! Nearly there!
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oParameter=oMyParameter.AddByExpression ("Length", "1", UnitsTypeEnum.kMillimeterLengthUnits)
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
oSheetMetalCompDef = ThisDoc.Document.ComponentDefinition
If oSheetMetalCompDef.HasFlatPattern = True Then
Parameter("Length") = SheetMetal.FlatExtentsLength
End If
Dim oOD, oTHK, oLength, oWidth As Parameter
Dim oFormat As CustomPropertyFormat
oOD = Parameter.Param("OD")
oOD.ExposedAsProperty = True
oFormat=oOD.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oTHK = Parameter.Param("THK")
oTHK.ExposedAsProperty = True
oFormat=oTHK.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oLength = Parameter.Param("Length")
oLength.ExposedAsProperty = True
oFormat=oLength.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
oWidth = Parameter.Param("Width")
oWidth.ExposedAsProperty = True
oFormat=oWidth.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision
oFormat.Units="mm"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False
iProperties.Value("Project", "Description") = "=<Width> x <THK> Thk Plate ~ Rolled to <OD> O/D"
Try this:
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters Try i = oMyParameter.Item("Length").Value Catch oParameter=oMyParameter.AddByExpression ("Length", "1", UnitsTypeEnum.kMillimeterLengthUnits) End Try Dim oSheetMetalCompDef As SheetMetalComponentDefinition oSheetMetalCompDef = ThisDoc.Document.ComponentDefinition If oSheetMetalCompDef.HasFlatPattern = True Then Parameter("Length") = SheetMetal.FlatExtentsLength End If Dim oOD, oTHK, oLength, oWidth As Parameter Dim oFormat As CustomPropertyFormat oOD = Parameter.Param("OD") oOD.ExposedAsProperty = True oFormat=oOD.CustomPropertyFormat oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.Units="mm" oFormat.ShowUnitsString=False 'set to show/not show the unit string (use True to show) oFormat.ShowUnitsString=False 'set to show/not show the trailing zeros (use True to show) oFormat.ShowTrailingZeros = False 'set to show/not show the leading zeros (use True to show) oFormat.ShowLeadingZeros = False oTHK = Parameter.Param("THK") oTHK.ExposedAsProperty = True oFormat=oTHK.CustomPropertyFormat oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.Units="mm" oFormat.ShowUnitsString=False 'set to show/not show the unit string (use True to show) oFormat.ShowUnitsString=False 'set to show/not show the trailing zeros (use True to show) oFormat.ShowTrailingZeros = False 'set to show/not show the leading zeros (use True to show) oFormat.ShowLeadingZeros = False oLength = Parameter.Param("Length") oLength.ExposedAsProperty = True oFormat=oLength.CustomPropertyFormat oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.Units="mm" oFormat.ShowUnitsString=False 'set to show/not show the unit string (use True to show) oFormat.ShowUnitsString=False 'set to show/not show the trailing zeros (use True to show) oFormat.ShowTrailingZeros = False 'set to show/not show the leading zeros (use True to show) oFormat.ShowLeadingZeros = False oWidth = Parameter.Param("Width") oWidth.ExposedAsProperty = True oFormat=oWidth.CustomPropertyFormat oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kZeroDecimalPlacePrecision oFormat.Units="mm" oFormat.ShowUnitsString=False 'set to show/not show the unit string (use True to show) oFormat.ShowUnitsString=False 'set to show/not show the trailing zeros (use True to show) oFormat.ShowTrailingZeros = False 'set to show/not show the leading zeros (use True to show) oFormat.ShowLeadingZeros = False iProperties.Value("Project", "Description") = "=<Width> x <THK> Thk Plate ~ Rolled to <OD> O/D"
Cheers Mike! That is spot on!