How to use iPart.ChangeRow

How to use iPart.ChangeRow

piotrekdoro94
Advocate Advocate
493 Views
3 Replies
Message 1 of 4

How to use iPart.ChangeRow

piotrekdoro94
Advocate
Advocate

Hi, I'm trying to simply change the value of a parameter in an IPart using an "iPart.ChangeRow" Ilogic command but I have a problem figuring out what arguments I should use.

 

Let's say I have a file called TestCube which is an IPart. In the IPart table I have two members:

 

Member: TestCube-01; Part Number (pl: Numer części):  TestCube-01; SideLength: 50

Membet: TestCube-02; Part Number:  TestCube-02; SideLength: 100

 

Now If an active member is TestCube-01 and I want to change the SideLength parameter for TestCube-02 I need to add following rule:

iPart.ChangeRow("???", "???") //What arguments should I put here?
Parameter("SideLength") = 50
iLogicVb.UpdateWhenDone = True

I've read the documentation for iPart.ChangeRow() function but I still can't figure out what arguments should I use because no matter what combination I try I get an object reference error.

 

TestCubeTable.jpg

TestCubeRule.jpg

0 Likes
Accepted solutions (1)
494 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @piotrekdoro94.  The online documentation for the iPart.ChangeRow method says that the first input variable is for the name of the assembly component that represents the iPart that you want to change, and if left empty, it will attempt to target the active document itself.  The second input being requested is to specify which row of the iPartFactory you want this assembly component (or active document) to switch to, and it will accept either an Integer for the Index of the row, or the MemberName (String).  I assume the third input (an array of Object) is likely only used for when it is a custom member of a custom factory table, for specifying member name, value pairs.  I do not believe that you can use the iPart.ChangeRow method to change parameter values of existing iPart members in the table.  To change the second member's parameter value from 100 to say 200, you would have to access the iPartFactory table directly.  To get that, when the active document is the iPart factory, you could use something like:

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oFactory As iPartFactory = oPDef.iPartFactory
Dim oRows As iPartTableRows = oFactory.TableRows
For Each oRow As iPartTableRow In oRows
	If oRow.MemberName = "TestCube-02" Then
		oRow.Item("SideLength").Value = 200
	End If
Next

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

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

piotrekdoro94
Advocate
Advocate

All right, thank you for help, it works. Turns out that when skipping the first argument it isn't supposed to look like this:

iPart.ChangeRow(,"TestCube-02")

where it is completely missing but like this:

iPart.ChangeRow("", "TestCube-02")

where the argument is present but its value is an empty string

Message 4 of 4

piotrekdoro94
Advocate
Advocate
Thank you very much for help , I think I understand now. It should have been clear from your reply in the last thread but I didn't realize I had to be so specific. I thought that if I change an active member and then update the parameter in the parameter table the iPart table would hava updated automatically too before switching to the next member.
0 Likes