Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Rule to Change Parameter Values

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
JazzJPH13
5338 Views, 9 Replies

iLogic Rule to Change Parameter Values

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.  


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)
9 REPLIES 9
Message 2 of 10
mrattray
in reply to: JazzJPH13

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

 

 

Mike (not Matt) Rattray

Message 3 of 10
JazzJPH13
in reply to: mrattray

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...


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)
Message 4 of 10
mrattray
in reply to: JazzJPH13

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

 

 

Mike (not Matt) Rattray

Message 5 of 10
JazzJPH13
in reply to: mrattray

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?


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)
Message 6 of 10
JazzJPH13
in reply to: JazzJPH13

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!


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)
Message 7 of 10
mrattray
in reply to: JazzJPH13

Post what you have now.
Mike (not Matt) Rattray

Message 8 of 10
JazzJPH13
in reply to: mrattray

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"


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)
Message 9 of 10
mrattray
in reply to: JazzJPH13

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"

 

Mike (not Matt) Rattray

Message 10 of 10
JazzJPH13
in reply to: mrattray

Cheers Mike! That is spot on!


Dell Precision T1700
Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz (4 Cores)
Windows 7 64-Bit
16.0 GB RAM
NVIDIA Quadro K2200 (12002 MB / 4096 MB)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report