iLogic to drive iPart selection

iLogic to drive iPart selection

Anonymous
Not applicable
2,052 Views
8 Replies
Message 1 of 9

iLogic to drive iPart selection

Anonymous
Not applicable

Hi all,

 

I've scoured the forum and the web for a solution to my problem, and even the similar cases I've found haven't been able to resolve this for me.

 

I'm helping my company build out a form and corresponding iLogic to drive a part configurator for our products; the form works, as does a lot of the iLogic I've built, save for this one snippet relating to selecting the iPart row.  BAG_CUSTOMBAG is a boolean parameter and BAG_VOLUME is a multivalue numerical parameter; the table member names correspond to values of BAG_VOLUME.  

 

I've tried removing ":1" after the part name, tried using just a name of a member instead of the BAG_VOLUME parameter, tried ensuring that the value of BAG_VOLUME is being converted to a string, and still get the same error:

 

Error in rule: BAG CONFIGURATOR, in document: 2D BAG (3 SEAM).ipt

Object reference not set to an instance of an object.

 

Anyone have any advice on what I'm missing here?

 

If Parameter("BAG_CUSTOMBAG")= False Then
    iPart.ChangeRow("2D BAG:1", Parameter("BAG_VOLUME"))
    Else    iPart.ChangeRow("2D BAG:1:)", "CUSTOM")
EndIf
0 Likes
2,053 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Hi

Looking at this line of your code

"iPart.ChangeRow("2D BAG:1", Parameter ("BAG_VOLUME"))"

 

I assume 2D BAG:1 is the component name in your model tree. Have you stabalized the name? By that I mean that you must rename the component in the model tree.

There should be no need for "Parameter" before BAG_VOLUME

 

So try this , "MY BAG" is the stabalized name I used

 

iPart.ChangeRow("MY BAG",BAG_VOLUME)

 

You may already have tried some or all of this, if so my apologies

0 Likes
Message 3 of 9

Anonymous
Not applicable
I believe I've stabilized the name correctly; just changing the name of the part at the top of the model tree, correct?

I tried changing it again and removing the "Parameter" from the second half of the command, still no luck though, getting the same error.

Any other thoughts on what it could be?
0 Likes
Message 4 of 9

Anonymous
Not applicable

can you try running the rule with the line

iPart.ChangeRow("2D BAG:1", "BAG_VOLUME")

just comment out the other lines, right now i am not sure which part of the code is failing.

If you could post a snapshot of your ipart author table I can try recreating the issue

0 Likes
Message 5 of 9

Anonymous
Not applicable

Sure, you can find it attached.

 

I tried commenting out the code except for the iPart.change, still no luck.  For reference, I stablized my part name to "DPPW".

0 Likes
Message 6 of 9

Anonymous
Not applicable

So to be clear.

You assembled the component into the assembly and stabalized the name in the assembly model tree to DPPW

This should work!

I will try to work up an example here to test this, what version of Inventor are you working with?

0 Likes
Message 7 of 9

Anonymous
Not applicable
Inventor 2013.

But no, I've only been running this script / form in the part file, I haven't tried it in an assembly yet - I just assumed that since it wasn't working at the part level that it wouldn't at the assembly level. Should I try it in an assembly?
0 Likes
Message 8 of 9

Anonymous
Not applicable

Absolutely,

The code should reside in the assembly.It will be triggered (executed) when the value of your parameter BAG_VOLUME changes

Then the ipart member will swap out

0 Likes
Message 9 of 9

Anonymous
Not applicable

Hi,

You may have stabilized the name, but when i saw your JPG file, i didnt find any column Name with "BAG_VOLUME"

 

iPart.ChangeRow("DPPW:1", 8)

 

If you have doubt still in handling kindly check my example file at: http://grabcad.com/library/ilogic-ipart-and-imate-1

 

The below code will allow you to pick your component and modify based on selection

 

Dim comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Component to change:")
'MsgBox(comp.Name)
DefaultRowNumber = iPart.RowNumber(comp.Name)
'rowName = iPart.RowName(comp.Name)
'
rowstringvalue=iPart.CurrentRowStringValue("Member")
'
MsgBox("Default Row No= " & GetDefaultRowNumber & " RowName==> " & rowName & " RowStringValue==> " & rowstringvalue)

i = iPart.FindRow(comp.Name,"Member","=","CUSTOM") ' To set last row no to Dim i
'MsgBox("Row No= " & i)
j=1
Component.Visible(comp.Name)=False
Dim sizelist As New ArrayList
For j = 1 To i
iPart.ChangeRow(comp.Name,j)
rowstringvalue=iPart.CurrentRowStringValue("Part Number")
'MsgBox("Row String Value= " & rowstringvalue)
sizelist.Add(rowstringvalue)
'MsgBox("j= " & j)
Next j
'MsgBox("j= " & j)
iPart.ChangeRow(comp.Name,j-1)
'sizelist.Add(rowstringvalue)
iPart.ChangeRow(comp.Name,DefaultRowNumber)
Component.Visible(comp.Name)=True
sizelist1= InputListBox("Select sizelist ", sizelist, sizelist, Title := "Select Sizelist", ListName := "Select Sizelist")
j = iPart.FindRow(comp.Name,"Part Number","=",sizelist1)

'ThisApplication.CommandManager.StartCommand(2344) ' kZoomAllCommand = 2344
'
ThisApplication.CommandManager.StartCommand(2353) ' kPanCommand = 2353

accept = InputRadioBox("Accept or Reject to change size", "Accept", "Reject", accept, Title := "Accept or Reject to change size")
'Run rule based On selection
While accept <> True
sizelist1= InputListBox("Select sizelist ", sizelist, sizelist, Title := "Select Sizelist", ListName := "Select Sizelist")
j = iPart.FindRow(comp.Name,"Part Number","=",sizelist1)
ThisApplication.CommandManager.StartCommand(2344) ' kZoomAllCommand = 2344
accept = InputRadioBox("Accept or Reject to change size", "Accept", "Reject", True, Title := "Accept or Reject to change size")
MsgBox(accept)
'yesorno=MessageBox.Show("Are you sure you want to use this size?","iLogic",MessageBoxButtons.YesNo)
If accept <> True 'Or yesorno= vbYes
iPart.ChangeRow(comp.Name,DefaultRowNumber)
End If
End While

'Dim Currentpartno= iPart.CurrentRowStringValue("Part Number")
'
MsgBox("Current Part No= " & Currentpartno)
'Tubelength = InputBox("Enter Tubelength", "Tubelength", "10")
'MsgBox("j= " & j)
'iPart.ChangeRow(comp.Name,iPart.RowName(comp.Name),Tubelength)
ThisApplication.CommandManager.StartCommand(2344)
'ThisApplication.ActiveView.Fit

 

0 Likes