iProperties functions in iLogic

iLogic provides rule functions for setting or getting the iProperties of Inventor part, assembly, and drawing documents. As rules are used to morph or modify designs into new configurations, keep the iProperties of the design documents updated. iProperties must be up to date for the Bill of Material to be correct. Rules can also be used to read the iProperty values of a document and react to them. For example, you can have a rule that changes the thickness of a part when the material property is changed. A rule can cause changes if the mass of the part exceeds a maximum or minimum. Any iProperty that can be set manually can be set or read using a rule.

To access the iProperties functions, expand the iProperties node under the System tab in the Snippets area.

iProperties.Value

Syntax

iProperties.Value("property tab name", "property name")

Reads or sets a property value in the document that contains the rule.

iProperties.Value("filename.ipt", "property tab name", "property name")

Used in an assembly level rule to access the iProperties of a part or subassembly.

If the file name of the part or subassembly is changed, the rule text must also be changed.

It is best to use the component name (after customizing it) rather than the file name.

iProperties.Value("custom component name", "property tab name", "property name")

Sets or reads the property values in a component. This function uses the component name rather than the file name. Customize the component name (change it from its original default name) so that it does not change if the file reference changes.

Examples

Set the iProperty value:

iProperties.Value("Project", "Stock Number") = "302A"

Read the iProperty value:

MyStringParam = iProperties.Value("Project", "Stock Number")

Set custom iProperty value:

iProperties.Value("Custom", "Age") = 41 'number type
iProperties.Value("Custom", "Company") = "Autodesk, Inc" 'text type
iProperties.Value("Custom", "Date") = CDate("11/1/2008") ' date type
iProperties.Value("Custom", "Insured") = true 'yes or no type

Read custom iProperty value:

age = iProperties.Value("Custom", "Age")
company = iProperties.Value("Custom", "Company")
thedate = CStr(iProperties.Value("Custom", "Date"))
insured = iProperties.Value("Custom", "Insured")

Things to remember

Deprecated functions

Previous iLogic versions used the following functions to get the iProperties from parts in assemblies:

iProperties.ValueInDoc("filename.ipt", "property tab name", "property name")

References the file name.

iProperties.ValueInComponent("custom component name", "property tab name", "property name")

References the component name.

Although these functions are not available in the Snippets area of the Edit Rule dialog box, they work if used in a rule. However, the iProperties.Value function is preferred instead of these older functions.

iProperties.StylesInEnglish

This function supports the use of the same document in different language versions of Autodesk Inventor. Your model is more portable when you use English names for materials and colors in your rules. If you set this function to True, then any function that returns any material or color names returns the names in English. You can use names in the language of your Autodesk Inventor installation to set a material or color name. But it is recommended that you use English names for consistency. The following functions return names in English when you set the iProperties.StylesInEnglish value to True:

iProperties.Material

Sets or reads the material of a document.

When setting the material, use the exact material name (case sensitive) as it appears in the active standard physical materials list. Material values are always text strings, enclosed within quotation marks.

Examples

To set the material:

iProperties.Material = "Gold"

To read the material:

MyStringParam = iProperties.Material

iProperties.Material(“filename.ipt”)

Sets or reads the material of a part within an assembly, by specifying the filename.

iProperties.Material(“componentName:1”)

Used in an assembly level rule to access the material of a part in the assembly, by specifying the component name.

iProperties.PartColor

Sets or reads the current color of a part. Part Color values are text strings enclosed in quotation marks. Changing the color does not affect the current material value.

This function works for parts only.

Examples

To set the color:

iProperties.PartColor = "Green"
iProperties.PartColor = "As Material"

To read the color:

MyStringParam = iProperties.PartColor

iProperties.Mass

Reads or writes the mass of the part or assembly document containing the rule.

If you write to the mass, it overrides the calculated mass. To restore the calculated value, set the mass to -1.

iProperties.Mass(“filename.ipt”)

Reads or writes the mass of a part or subassembly in an assembly, by specifying the filename.

iProperties.Mass(“component name:1”)

Reads or writes the mass of a component in an assembly, by specifying the component name. This function can also be used to read or write to the mass of a virtual component.

Examples

To read the mass:

MyMassParam = iProperties.Mass
MyMassParam = iProperties.Mass("component:1")
MyMassParam = iProperties.Mass("mypart.ipt")

To set the mass (override automatic calculation):

iProperties.Mass = 3 kg
iProperties.Mass("virtual_component") = 233 g
iProperties.Mass("mypart.ipt") = 4.2 lb
massiProperties.Mass = -1 'set the mass back to automatic calculation

iProperties.Volume

Reads or writes the volume of the document containing the rule.

iProperties.Volume(“filename.ipt”)

Reads or writes the volume of the part or subassembly containing the rule, by specifying the filename.

iProperties.Volume(“component:1”)

Reads or writes the volume of a component in an assembly, by specifying the component name. This function can also be used to read or write to the volume of a virtual component.

Examples

To read the volume:

MyVolumeParam = iProperties.Volume
MyVolumeParam = iProperties.Volume("component:1")
MyVolumeParam = iProperties.Volume("mypart.ipt")

To set the volume (override automatic calculation):

iProperties.Volume = 12.4 in^3
iProperties.Volume("virtual_component") = 542 cm^3
iProperties.Volume("mypart.ipt") = 12.8 in^3
iProperties.Volume = -1 'set it back to automatic calculation

iProperties.CenterOfGravity

Reads the center of gravity of the model in the document containing the rule.

Syntax

pt = iProperties.CenterOfGravity

pt is of the type Inventor.Point, which is described in the Help for Inventor API. You can read the X, Y, and Z values of the point, expressed in the units of the rule document:

cx = pt.X
cy = pt.Y
cz = pt.Z

pt = iProperties.CenterOfGravity("component")

Reads the center of gravity of a component in an assembly, specifying the component name.

iProperties.Area

Reads the surface area of the model in the document containing the rule.

Syntax

surfaceArea = iProperties.Area

surfaceArea = iProperties.Area(“component:1”)

Reads the surface area of a component in an assembly, by specifying the component name.