For Each Loop in iLogic Rule

For Each Loop in iLogic Rule

ulasdeniz
Mentor Mentor
4,689 Views
5 Replies
Message 1 of 6

For Each Loop in iLogic Rule

ulasdeniz
Mentor
Mentor

Hi. I am new in visual basic. I am trying to automatically create a list of parts that are changing dimensions by a parameter. So I need a for loop to change the parameter and save the file for each value in the list.  (this is just a first step, in second step I will create a nested loop.)

 

I tried to write a rule but it doesnt work. Can you help me? 

 

 

SyntaxEditor Code Snippet

    For Each index In  {2, 4, 6}
        BB = index * 10

    iLogicVb.UpdateWhenDone = True
    ThisDoc.Document.SaveAs("dd" & ".ipt" , False)
    Next 
    

 


Ulaş Deniz


Forumlarımızda çözülen sorularınızı "ÇÖZÜM OLARAK KABUL ET" ( "ACCEPT AS SOLUTION" ) seçimiyle işaretlemeyi lütfen unutmayın.
Beğendiğiniz mesajları lütfen "Övgü Puanı" (KUDO) ile ödüllendirin.
Youtube : https://www.youtube.com/channel/UCkJpVueGScmJvW1RIgqttSg

0 Likes
Accepted solutions (1)
4,690 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor
If you can post screenshots of the error windows that is always useful for us to diagnose what is wrong.

For additional iLogic/vb.net info check out the blogs:

http://beinginventive.typepad.com/being-inventive/
http://adndevblog.typepad.com/manufacturing/
http://modthemachine.typepad.com/my_weblog/

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 6

ulasdeniz
Mentor
Mentor

Thank you. the errors are in below When I delete the update and save as rows (last two rows before the Next statement) the rule works and model parameter is changing. 

 

Capture_error.JPG

 

Capture_error2.JPG


Ulaş Deniz


Forumlarımızda çözülen sorularınızı "ÇÖZÜM OLARAK KABUL ET" ( "ACCEPT AS SOLUTION" ) seçimiyle işaretlemeyi lütfen unutmayın.
Beğendiğiniz mesajları lütfen "Övgü Puanı" (KUDO) ile ödüllendirin.
Youtube : https://www.youtube.com/channel/UCkJpVueGScmJvW1RIgqttSg

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor
Accepted solution
As you can see i the second window, working from the bottom up, we see the issue goes from iLogic (which is the add-in) > ExecRuleInAssembly (The active assembly file) > Main (the rule in the assembly) > Document.SaveAs (A line/function trying to be performed by the Rule) > ForwardCall (the exact problem the program is running into).

From the last 2 things listed (or the first 2 from the top in the window) we can see it is an issue with the same (why you see SaveAs in there) and an issue with something we don't know (forwardcall - upon research, you will find this actually has to do with calling an invalid variable as a parameter).

From experience, the examples in the API help, and help in the forums, I have learned this specific situation is caused by the fact that you don't have the full file string listed in your saveas arguements. You need a string such as: "C:\Users\Bob\File.ipt"

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 6

ulasdeniz
Mentor
Mentor

Thank you. İt is solved as you stated. Full path name is rrequired. some functions doe not require the path name as using the current document path.  

 

But I have enother problem. My code is working, the parameters are changed. but the prametric flush constraint couldnt changed. I did everything. Document update. Add flush constraint's dimension into code and connected to the index parameter, placing update statement every row where the model is changed. But ı couldnt solved this. 


Ulaş Deniz


Forumlarımızda çözülen sorularınızı "ÇÖZÜM OLARAK KABUL ET" ( "ACCEPT AS SOLUTION" ) seçimiyle işaretlemeyi lütfen unutmayın.
Beğendiğiniz mesajları lütfen "Övgü Puanı" (KUDO) ile ödüllendirin.
Youtube : https://www.youtube.com/channel/UCkJpVueGScmJvW1RIgqttSg

0 Likes
Message 6 of 6

Z0methink
Enthusiast
Enthusiast
'This Is code for changing the parameters of components from an assembly.
'If there Is no such parameter in the component, then the error Is ignored.

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisDoc.Document
Dim  oAsmCompDef As  AssemblyComponentDefinition 
oAsmCompDef = oAsmDoc.ComponentDefinition 

Parameter.Quiet = True
For Each occComp As Inventor.ComponentOccurrence In oAsmCompDef.Occurrences
	Parameter(occComp.Name, "d0") = d0
	Parameter(occComp.Name, "d1") = d1
	Parameter(occComp.Name, "d2") = d2
Next
Parameter.Quiet = False
0 Likes