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.
Solved! Go to Solution.
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?
Try
Constraint.IsActiveInDoc("Upper Section Assembly:1", "Mate:8") = True
strange why the original code does not work
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.
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
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 🙂
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
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.