Save multivalue itens automatically in iLogic

Save multivalue itens automatically in iLogic

alex.xavier
Explorer Explorer
656 Views
5 Replies
Message 1 of 6

Save multivalue itens automatically in iLogic

alex.xavier
Explorer
Explorer

Hello, I made an part using iLogic. This part will have some items and each item will have an especific dimension. I'm using multivalue field with excel table and it's contain all dimensions, associating each item with each dimension. When I was done the table, I would like to save each item with especific name listed in multivalue field automatically. Now, I do this manually, selecting item in multivalue field and clicking in Save Buttom that I was created with this rule:

 

ThisDoc.Document.SaveAs ("..\3D_Pumps\" & Tag_Pump & ".ipt", True).

I would like to do this automatically using some rule. This rule will see all items in multivalue field and save with this name and with all dimensions of this especific item. Is it possible?

 

Thks,

 

Alex

0 Likes
Accepted solutions (1)
657 Views
5 Replies
Replies (5)
Message 2 of 6

rjay75
Collaborator
Collaborator

Loop through the values of the list, set the parameter to the value and update the part to the new dimensions, save the part.

 

 

'Get Multivalue Parameter Values
values = MultiValue.List("Tag_Pump") For Each value In values Parameter("Tag_Pump") = value

'DO WHATEVER ELSE NEEDS TO BE DONE TO CHANGE THE PART
InventorVb.DocumentUpdate()
ThisDoc.Document.SaveAs ("..\3D_Pumps\" & Tag_Pump & ".ipt", True) Next value
Message 3 of 6

alex.xavier
Explorer
Explorer

Hi rjay75

 

Thanks for your attention.

 

 

I tried this function but doesn't work. Its saves the same TAG all the time.

 

I have this

Form.JPG

 

I'm using excel table for multivalue list. That' no problem, right?

MultiValue.List("Tag_Bomba") = GoExcel.CellValues(Bombas, "Tabela_Bombas", "A2", "A100")

 

 

About your code I just accept the names of the values:

 

'Get Multivalue Parameter Values
values = MultiValue.List("Tag_Bomba")

For Each value In values
    Parameter("Tag_Bomba") = value
    InventorVb.DocumentUpdate()
    ThisDoc.Document.SaveAs ("..\3D_Pumps\" & Tag_Bomba & ".ipt", True)
Next value

 

 

I did some thing wrong?

 

Thanks

0 Likes
Message 4 of 6

rjay75
Collaborator
Collaborator
Accepted solution

In the saveas statement instead of using the dynamic parameter variable Tag_Bomba use the variable 'value' instead since that is has the value we just set the parameter to prior.

 

'Get Multivalue Parameter Values
values = MultiValue.List("Tag_Bomba")

For Each value In values
    Parameter("Tag_Bomba") = value
    InventorVb.DocumentUpdate()
    ThisDoc.Document.SaveAs ("..\3D_Pumps\" & value & ".ipt", True)
Next value

Note from the iLogic help file:

 

Parameters can appear in two different ways:

 

  • VB.NET variables that are linked to numeric or non-numeric parameters. The variables are highlighted in blue:

    When a rule starts running, iLogic reads the values for these parameters from the model into the rule. When the rule has finished running, iLogic saves the changed values back to the model.

    To save the values before the rule has finished running, use the RuleParametersOutput function. This function is useful if you want to change the model immediately.

  • Parameters accessed using the Parameter function. For example:

    When you assign values using this method, the values are saved to the model immediately, before the next line in the rule runs. When you read a value using the Parameter function, it is immediately read from the Inventor model.

 

Because you want to have the document update immediately to the parameter change so you can save it you use the Parameter("Tag_Bomba") method to update it.

Message 5 of 6

alex.xavier
Explorer
Explorer

it works!

 

I just add to run one more rule, that read all value of excel table.

 

'Get Multivalue Parameter Values
values = MultiValue.List("Tag_Bomba")

For Each value In values
    Parameter("Tag_Bomba") = value
    InventorVb.DocumentUpdate()
	iLogicVb.RunRule("Lista de Bombas")
	RuleParametersOutput()

    ThisDoc.Document.SaveAs ("..\3D_Pumps\" & value & ".ipt", True)
Next value

I don't understand about RuleParametersOutput(). Is it needed?

 

I removed this line and tested and the effect was the same

 

 

Just one more question. It's possible to create an window that I select with itens I'll save? How?

 

 

Thks a lot!

0 Likes
Message 6 of 6

rjay75
Collaborator
Collaborator

The RuleParametersOutput() is not needed.

 

When I have a chance I will look into a method to do name selection.

0 Likes