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
ClintWestwood
7827 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.

Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
11 REPLIES 11
Message 2 of 12
mrattray
in reply to: ClintWestwood

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

Message 3 of 12
ClintWestwood
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?

 

Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Message 4 of 12
swordmaster
in reply to: ClintWestwood

Try

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

 

strange why the original code does not work

Inventor 2010 Certified Professional
Message 5 of 12
ClintWestwood
in reply to: swordmaster

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.

Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Message 6 of 12
swordmaster
in reply to: ClintWestwood

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

 

Inventor 2010 Certified Professional
Message 7 of 12
ClintWestwood
in reply to: swordmaster

That seems to have done the trick! Thanks so much.
Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Message 8 of 12
swordmaster
in reply to: ClintWestwood

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 🙂

Inventor 2010 Certified Professional
Message 9 of 12
mrattray
in reply to: ClintWestwood

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

Inventor 2010 Certified Professional
Message 11 of 12
ClintWestwood
in reply to: swordmaster

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

Inventor 2014
HP Pavilion dv6t-6b00
Intel Core i7 2670QM
AMD Radeon HD 6490M
16gb RAM
Windows 7 64 bit
3Dconnexion SpaceExplorer
Message 12 of 12
Anonymous
in reply to: swordmaster

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  

Autodesk Design & Make Report