Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic to drive iPart selection

8 REPLIES 8
Reply
Message 1 of 9
CADyShaq99
1791 Views, 8 Replies

iLogic to drive iPart selection

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
8 REPLIES 8
Message 2 of 9
swordmaster
in reply to: CADyShaq99

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

Inventor 2010 Certified Professional
Message 3 of 9
CADyShaq99
in reply to: swordmaster

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?
Message 4 of 9
swordmaster
in reply to: CADyShaq99

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

Inventor 2010 Certified Professional
Message 5 of 9
CADyShaq99
in reply to: swordmaster

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".

Message 6 of 9
swordmaster
in reply to: CADyShaq99

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?

Inventor 2010 Certified Professional
Message 7 of 9
CADyShaq99
in reply to: swordmaster

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?
Message 8 of 9
swordmaster
in reply to: CADyShaq99

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

Inventor 2010 Certified Professional
Message 9 of 9
Carthik_Babu
in reply to: CADyShaq99

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

 

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report