INV 2021 is active sub-assembly

INV 2021 is active sub-assembly

blandb
Mentor Mentor
436 Views
4 Replies
Message 1 of 5

INV 2021 is active sub-assembly

blandb
Mentor
Mentor
Constraint.IsActive("SubAssem:1", "Mate:1")


this Code does not appear to be working. I have read that you must give the actual sub-assembly name, not the stagnated browser name for this to work, but that seems to kills the productivity. If we were to stagnate browser names for other things to work better, why would you not want to do it for this? If I try to place in my browser name in "subAssem:1" place, it will not find the relationships, but if I use the real assembly name with the extension, then it will..... 

Autodesk Certified Professional
0 Likes
437 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

I'm using Inventor Pro 2021.1, and I just tested both versions of that code on a test assembly, and they both worked for me.  The documentation for retrieving these Properties does not mention whether this Property is a ReadOnly or not, but my tests prove that it is a Get/Set (not ReadOnly), because I can change the 'Suppressed' status of a constraint with them.

These are the two variations of code I was using on my assembly, and I confirmed by looking at my constraints in the model browser tree that both worked to Suppress the target constraint.

'Constraint.IsActive("Mate:1") = False
'MsgBox(Constraint.IsActive("Mate:1"))

Constraint.IsActive("TestPart1:1","Mate:1") = False
MsgBox(Constraint.IsActive("TestPart1:1","Mate:1"))

These are the pages of documentation I was referring to:

IAssemConstraint Interface 

IAssemConstraint.IsActive Property (String) 

IAssemConstraint.IsActive Property (Object, String) 

 and here is another link, maybe unrelated link about Constraints

IManagedConstraints Interface 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

Daan_M
Collaborator
Collaborator

Maybe rename your contrains as well?

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Another thing you can try that works for me is to use 'oOcc.Name' in place of the manually typed-in String for its browser name (where oOcc is one of the ComponentOccurrence involved in that constraint).  Or in the case where that component is a sub-assembly (won't work if it's a part), I believe using that components document DisplayName will usually also work (as long as the DisplayName hasn't been manipulated from its default - FileName with extension and no path).

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

blandb
Mentor
Mentor

I did rename the constraint as well, and I kept getting an error message stating that it couldn't be found. I didn't try using the MakePath option yet, I thought about it lastnight after I posted. I took it as based on what the snippet was doing I  wouldn't need to use the makepath syntax.

Autodesk Certified Professional
0 Likes