iLogic rule for subassembly constraints

iLogic rule for subassembly constraints

Anonymous
Not applicable
8,298 Views
11 Replies
Message 1 of 12

iLogic rule for subassembly constraints

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
8,299 Views
11 Replies
Replies (11)
Message 2 of 12

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

0 Likes
Message 3 of 12

Anonymous
Not applicable

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?

 

0 Likes
Message 4 of 12

Anonymous
Not applicable

Try

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

 

strange why the original code does not work

0 Likes
Message 5 of 12

Anonymous
Not applicable

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.

0 Likes
Message 6 of 12

Anonymous
Not applicable
Accepted solution

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
Not applicable
That seems to have done the trick! Thanks so much.
0 Likes
Message 8 of 12

Anonymous
Not applicable

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

0 Likes
Message 10 of 12

Anonymous
Not applicable

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

0 Likes
Message 11 of 12

Anonymous
Not applicable

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

0 Likes
Message 12 of 12

Anonymous
Not applicable

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?