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 rule for subassembly constraints

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
8116 Views, 11 Replies

iLogic rule for subassembly constraints

Is there a way to edit constraints inside a subassembly from the main assembly, using ilogic?

 

I would like to supress a constraint (let's call it mate:8), which is inside a subassembly. When I right click on that constraint, and select "Capture Current State", it inserts Constraint.IsActive("Mate:8") into my iLogic code. However, there is already a mate:8 in my main assembly, so how can I be more specific so that iLogic knows which constraint I am talking about?

 

I know that I can work around this, but I feel like this capability should exist, I just don't know about it yet.

11 REPLIES 11
Message 2 of 12
mrattray
in reply to: Anonymous

Constraint.IsActive("SubAssem:1", "Mate:1")
Mike (not Matt) Rattray

Message 3 of 12
Anonymous
in reply to: mrattray

That definately sounds right, but it doesn't seem to be working for me... In my main assembly I have 

Constraint.IsActive("Upper Section Assembly:1", "Mate:8") = True

but I get this error:

 

Error in rule: Existing Walls, in document: Final Assembly.iam

Constraint.IsActive: "Mate:8" was not found in the component: "Upper Section Assembly:1".

 

In my subassembly, I can type 

Constraint.IsActive("Mate:8") = True

and it works fine.

 

Can you see anything I'm doing wrong here?

 

Message 4 of 12
Anonymous
in reply to: Anonymous

Try

Constraint.IsActiveInDoc("Upper Section Assembly:1", "Mate:8") = True

 

strange why the original code does not work

Message 5 of 12
Anonymous
in reply to: Anonymous

Still doesn't Work 😕

 

It gives me the error:

 

Error in rule: Existing Walls, in document: Final Assembly.iam

Constraint.IsActiveInDoc("Upper Section Assembly:1", "Mate:8") : The document named "Upper Section Assembly:1" was not found.

Message 6 of 12
Anonymous
in reply to: Anonymous

My mistake! I should have mentioned that when you use Constraint.IsActiveInDoc you must use the sub-assembly file name

like this

Constraint.IsActiveInDoc

("option_3.iam", "Mate:5")= False

 

Message 7 of 12
Anonymous
in reply to: Anonymous

That seems to have done the trick! Thanks so much.
Message 8 of 12
Anonymous
in reply to: Anonymous

your welcome!

One thing i would suggest is that you rename the constraints you are controlling to something more meaninful.

In 6 months time you probably will not remember what Mate:8 is but if you rename it to "vertical offset"

you might 🙂

Message 9 of 12
mrattray
in reply to: Anonymous

You shouldn't have had to use IsActiveInDoc.
I suspect that you have a slight difference between the name specified in the code and the actual name of the sub. You need to have it match 100% dead nuts to the occurrence name as shown in the browser.
Mike (not Matt) Rattray

Message 10 of 12
Anonymous
in reply to: mrattray

Mike,

I totally agree that "IsActiveInDoc." should not be neccessary.

However, the code snippet  Constraint.IsActive("SubAssem:1", "Mate:1") does not work , at least not with ilogic 2009

I was able to recreate the error and i do not have any mismatch/spelling errors with the names. I use the ilogic interface to "transfer" the names to the ilogic code

 

 

Inventor 2009,windows xp 32 bit, excel 2000

Message 11 of 12
Anonymous
in reply to: Anonymous

Just noticed this today, would unchecking this box have anything to do with it?

Message 12 of 12
Anonymous
in reply to: Anonymous

I have a question what if I don't want to use the filename instead I want to use the display name since the file name is going to change every time I do a copy design. If I use the filename the code will need to be update or the rule won't work that will not be very efficient for people who are going to be using the ilogic assembly and don't know much about coding. Is there any other solution where the display name is used?

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report