Use iPart and iAssembly functions to drive iPart and iAssembly configurations in an assembly. You can use a rule to change the current configuration of an iPart or iAssembly based on the conditions and logic you define.
These functions work for iAssemblies in the same way as they do for iParts, except that custom parameters can only be used for iParts. To use the function for an iAssembly, you can optionally substitute iPart with iAssembly when specifying the function.
To access the iPart and iAssembly functions, expand the iParts node under the System tab in the Snippets area.
Similar functions are available for iFeatures. See iFeature functions for more information.
Changes the active row in an iPart or iAssembly table.
Syntax
iPart.ChangeRow("iChangedComponentName:1", "memberName")
“iChangedComponentName:1”
The name of the component as displayed in the Autodesk Inventor assembly browser. Change the default component name assigned by Inventor to stabilize it and prevent the name from changing when a different row is chosen in the table.
“memberName”
The name assigned to the row in the Member column of the table.
For an iPart with custom parameters, use this syntax to list the custom parameters after "memberName". Show them in the same order as they appear in the table:
iPart.ChangeRow("iChangedComponentName:1", "memberName", customParam1,customParam2)
Use this syntax to specify a row number instead of a member name. The row number is an integer, starting at 1 for the first row (for standard iParts only):
iPart.ChangeRow("iChangedComponentName:1", rowNumber)
Example
In this example, the current iPart configuration is changed based on a conditional statement that evaluates an Inventor user parameter Port_1_Size. The function requires only the iPart component name port_1_Flange_screw and the iPart table Member name Screw-01 to drive the active iPart configuration:
If Port_1_Size = .50 Then iPart.ChangeRow("port_1_flange_screw", "Screw-01") ElseIf Port_1_Size = .75 Then iPart.ChangeRow("port_1_flange_screw", "Screw-02") ElseIf Port_1_Size = 1.00 Then iPart.ChangeRow("port_1_flange_screw", "Screw-03") End If
Searches the iPart or iAssembly table by column for the row containing a specific or approximate value, and sets the active configuration to the row found.
Syntax
i=iPart.FindRow("iChangedComponentName:1", "columnName","<=",0.2,"columnName","<=", 4.1,"|",customParam1,customParam2)
i=iPart.FindRow("iChangedComponentName:1","columnName", "<=",d1,"columnName","<=",d2)
“i”
A local variable that can be used to test whether a valid row number is found.
“iChangedComponentName:1”
The name of the component as displayed in the Inventor assembly browser. Change the default component name assigned by Inventor to stabilize it and prevent the name from changing when a different row is selected in the table.
“columnName”
The column to search in the iPart table. Use the column header name exactly as it appears in the iPart table.
Example
This example searches an iPart table for a row with column values that are equal to or greater than the specified values. iLogic switches the current iPart configuration to the row found:
iPart.FindRow("port_1_flange_screw", "Thread_Diameter", ">=", 0.45, "Thread_Length", ">=", 2.0)
Once a row has been found using iPart.FindRow, this function reads associated column values from that row. This function reads numeric values only. Use iPart.CurrentRowStringValue to read columns containing text values.
Syntax
d0 = iPart.CurrentRowValue("columnName")
Any of the following sets the current row:
iPart.FindRow or iPart.ChangeRow.
“columnName”
The name of the iPart table column you want.
Example
In this example, we search the Port_Size column of the port_1_flare_flange iPart table for an exact value that matches the value of the Inventor parameter Port_1_Size. Once the row is found, we use iPart.CurrentRowValue to retrieve the dimensions from the A_dim and B_dim columns of the table. Then, we assign their values to the Inventor parameters named Port_1_screw_A_dim and Port_1_screw_B_dim:
i = iPart.FindRow("port_1_flare_flange", "Port_Size", "=", Port_1_Size) Port_1_screw_A_dim = iPart.CurrentRowValue("A_dim") Port_1_screw_B_dim = iPart.CurrentRowValue("B_dim")
Once a row has been found using iPart.FindRow, use this function to read associated column values from that row. This function is like iPart.CurrentRowValue, except that it reads text values only. Use iPart.CurrentRowValue to read columns containing numeric values.
Syntax
iPart.CurrentRowStringValue("PartNumber")
Alternative syntax for the component name
To specify a component name that does not change when the iPart row is changed.
iPart.ChangeRow("iParentFileName:1", "memberName")
iPart.FindRow("iParentFileName:1","columnName","<=",d1,"columnName","<=",d2)
“iParentFileName:1”
The iPart parent file name, where ":1" replaces the usual .ipt or .iam extension. Change the ":1" to the number of the component you are working with.
Although this syntax is supported, it is not recommended. A more standard method is to change the component name to stabilize it.
Gets the member name of the active row in an iPart or iAssembly component instance. This function is useful in rules triggered by the iPart or iAssembly Change Component event. Use iPart.ChangeRow or iPart.FindRow to select a row automatically from a rule. If you want to allow the user to select a row manually, you can combine that event with this function to react to the change.
Syntax
iPart.RowName("iChangedComponentName:1")
Example
memberName = iPart.RowName("port_1_flange_screw:1")
Gets the row number of the active row in an iPart or iAssembly component instance.
Syntax
iPart.RowNumber("iChangedComponentName:1")
Example
rowNumber = iPart.RowNumber("port_1_flange_screw:1")
Used with the iPart.FindRow function, this function allows you to search for a value within a range rather than searching for an exact value. There is always a tolerance for this search. The default tolerance is 0.0000001 and is not dependent on document units.
Syntax
iPart.Tolerance = <value>
Set a higher tolerance to expand the range of acceptable values.
Example
Suppose you use the following statements:
iPart.Tolerance = 0.001 i = iPart.FindRow("Block:1","length", "=", 2.3)
Together, these statements become equivalent to the following search with no tolerance:
i = iPart.FindRow("Block:1", "length", ">=", 2.299, "length","<=", 2.301)
To replace an iPart member with a member from a different factory, use Component.ReplaceiPart.