How to change iPart instences through iLogic form?

How to change iPart instences through iLogic form?

jeeva.scientist
Enthusiast Enthusiast
850 Views
6 Replies
Message 1 of 7

How to change iPart instences through iLogic form?

jeeva.scientist
Enthusiast
Enthusiast

1) I have an iPart with three rows of the table. so three parts with different dimensions.

2) they are

• Part1

• Part2

• Part3

3) now the first part1 is in active condition. I want to make part2 as active. But I want to do it from iLogic form by clicking a button or a dropbox or radio button

0 Likes
Accepted solutions (1)
851 Views
6 Replies
Replies (6)
Message 2 of 7

clutsa
Collaborator
Collaborator

Make a custom multi-value User Parameter (in this example its TargetPart) with your part names. Add a rule...

Dim doc As Document = ThisDoc.Document
Dim compDef As ComponentDefinition = doc.ComponentDefinition
Dim factory As iPartFactory = compDef.iPartFactory
Dim factoryRows As iPartTableRows = factory.TableRows
PartExists = False 'assume we won't find the part
For Each row In factoryRows
	If row.Item(2).value = TargetPart Then 'row.Item(2) is the Part Number column
		PartExists = True
		factory.DefaultRow = row
		Exit For
	End If
Next
If PartExists = False Then MessageBox.Show(TargetPart & " was not found.", "Title")

Create a new form and drag your user parameter (TargetPart) on to the form and save.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 7

jeeva.scientist
Enthusiast
Enthusiast

Picture1.png

 

Picture2.png

 

Picture3.png

 

i am getting some error

0 Likes
Message 4 of 7

clutsa
Collaborator
Collaborator

Leave the code just like I had it for the Row.Item(2).

Item(2) is the 2nd column in the row which happens to be the part number column. Row.Item(1) is the member name column if you want to look for member name not part numbers.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 5 of 7

jeeva.scientist
Enthusiast
Enthusiast

Picture4.png

 

I have attached the part file can you check if I made any other mistake, please.

0 Likes
Message 6 of 7

clutsa
Collaborator
Collaborator
Accepted solution

It's case sensitive. Try capitalizing the names in the list or add code to force the cases to be the same

Dim doc As Document = ThisDoc.Document
Dim compDef As ComponentDefinition = doc.ComponentDefinition
Dim factory As iPartFactory = compDef.iPartFactory
Dim factoryRows As iPartTableRows = factory.TableRows
PartExists = False 'assume we won't find the part
For Each row In factoryRows
	If UCase(row.Item(2).value) = UCase(TargetPart) Then 'row.Item(2) is the Part Number column
		PartExists = True
		factory.DefaultRow = row
		Exit For
	End If
Next
If PartExists = False Then MessageBox.Show(TargetPart & " was not found.", "Title")

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 7 of 7

jeeva.scientist
Enthusiast
Enthusiast

Working proofWorking proof

 

thank you very much for your support Mr. Andrew Cluts.