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 change factory part - syntax error?

7 REPLIES 7
Reply
Message 1 of 8
chrisjspower
546 Views, 7 Replies

ilogic to change factory part - syntax error?

Hi all, I'm learning how to use ilogic for inventor.
My current issue that I can't seem to get around is a syntax error.
I have obtained the correct syntax from the Autodesk website I need to use but I can't see where I am entering it incorrectly.
I am using assembly, with various iparts
I have a user parameter I named "Tank_Type_STANDARD" which I want to control the factory ipart that is loaded to the assembly. the goal is to create a form that can produce different variations of an assembly through basic changes made to the form.

 

my failing rule is as follows:

 

If Tank_Type_STANDARD = 1
Then iPart.ChangeRow("Tank_wall_base", "Tank_Lower_Section_01")
ElseIf Tank_Type_STANDARD = 2
Then iPart.ChangeRow("Tank_wall_base", "Tank_Lower_Section_02")
End If

 

Have I approached this problem incorrectly? can my goal be achieved? I will continue to try and solve this problem in the meantime. Any and all assistance is greatly appreciated.

regards,

Chris

 

7 REPLIES 7
Message 3 of 8
chrisjspower
in reply to: Xun.Zhang

Several hours in and I can't see where these suggestions relate or how to apply them. Everything I try comes back with syntax errors or does nothing.

This should be a pretty basic function, or I'm going about it the wrong way. I just want to change an ipart in assembly without manually doing so in the assembly tree.

 

thanks

 

Edit*
Not sure if part name is stabilized so will try this now

 

Message 4 of 8

FTFY

 

Structure is important in coding. The 'then'  needs to be at the end of the line (or not exist at all in some programming languages)

If Tank_Type_STANDARD = 1 Then 
    iPart.ChangeRow("Tank_wall_base", "Tank_Lower_Section_01")
ElseIf Tank_Type_STANDARD = 2 Then 
    iPart.ChangeRow("Tank_wall_base", "Tank_Lower_Section_02")
End If

--------------------------------------
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 8

Like this?

If Tank_Type_STANDARD = 3 
Then iPart.ChangeRow("Tank_Lower_Section", "T03")
Else If Tank_Type_STANDARD = 4 
Then iPart.ChangeRow("Tank_Lower_Section", "T04")
End If

 i get a syntax error on line 2 & 4 still whereas placing "then" at the "end" of line 1 & 2 produces no error.

thanks

Message 6 of 8
chrisjspower
in reply to: chrisjspower

Okay thanks that got me a step further, now i just have to figure out why it isn't finding the row.
I get this message:

"Error in rule: "rule", in document: "Assembly.iam"

 

iPart.ChangeRow: No iPart row with the specification "anthing i enter here" was found in the component "ipart".

 

when it refers to the row do I enter the member name, the part number or the number to the far left of the table?

 

thanks

Message 7 of 8

Yeah, could be it!

 

Simply trying things out and seeing what happens will probably get your results a lot faster than posting back to the forums every time.

 

Sounds like a reasonable assumption that it could be looking for information in the first column of the iPart table.

 

Or maybe the format of the table is off too.

 

You could always review the documentation in the help files about iPart iLogic too.


--------------------------------------
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 8 of 8

Oh I wasn't waiting for the solution, I was working on it the whole time, trying everything. 
In the end I re-started from scratch and used the same ilogic i started with and it worked. when I am back at work I will repost with my findings.
Thanks for your help!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report