iLogic rule for constraint suppressed/unsupressed dependant on active part

iLogic rule for constraint suppressed/unsupressed dependant on active part

jamieking89
Enthusiast Enthusiast
1,856 Views
8 Replies
Message 1 of 9

iLogic rule for constraint suppressed/unsupressed dependant on active part

jamieking89
Enthusiast
Enthusiast

 

Good morning

 

I was wondering if anyone could help me with iLogic for constraints. I have an adaptive pipe, which dependant on which one of 2 plates in the assembly is un-suppressed will be constrained to its bottom face.

 

What is the ilogic syntax for this? And also is it best to have one constraint from the top of the pipe face which will change what face it is constraint too dependant on what plate is active, or is it best to have 2 constraints one of which is suppressed if the component relating to it is suppressed?

 

i have attached the components and assembly also.

 

Cheers

Jamie

0 Likes
Accepted solutions (1)
1,857 Views
8 Replies
Replies (8)
Message 2 of 9

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @jamieking89 

First create the constraints and name them something like "Plate1_constraint" and "Plate2_constraint"

Add this rule to your assembly:

If Component.IsActive("Plate1:1") = True And Component.IsActive("Plate2:1") = False
	Constraint.IsActive("Plate2_constraint") = False
	Constraint.IsActive("Plate1_constraint") = True
ElseIf Component.IsActive("Plate1:1") = False And Component.IsActive("Plate2:1") = True
	Constraint.IsActive("Plate1_constraint") = False
	Constraint.IsActive("Plate2_constraint") = True
Else
	Constraint.IsActive("Plate1_constraint") = False
	Constraint.IsActive("Plate2_constraint") = False
End If
ThisDoc.Document.Rebuild
	
	

I named the rule ActiveConstraint.

Add a trigger for the rule on Component Suppression Change.

Constraints.PNG

Hope it helps 🙂

0 Likes
Message 3 of 9

JhoelForshav
Mentor
Mentor
0 Likes
Message 4 of 9

jamieking89
Enthusiast
Enthusiast

That works great thanks.

 

Are you aware if i can do a smilar thing with only using 1 constraint but changing the plate face in the constraint dependant on the suppression of components using ilogic?

 

Thanks for your help!

 

Jamie

0 Likes
Message 5 of 9

JhoelForshav
Mentor
Mentor

Hi @jamieking89 

Happy to help!

 

You can do that but it's much more complex. Try the iLogic code below. You'll have to make a constraint and name it

Plate_Constraint in which the first entity in the constraint is "Top_of_pipe_plane" and the second is one of the planes from your parts.

You should have the same event trigger as before.

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oConstraint As MateConstraint = oDoc.ComponentDefinition.Constraints.Item("Plate_Constraint")

Dim oPlaneProx1 As WorkPlaneProxy = Nothing
Dim oPlaneProx2 As WorkPlaneProxy = Nothing
Dim oPlate1 As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.ItemByName("Plate1:1")
Dim oPlate2 As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.ItemByName("Plate2:1")

If Component.IsActive("Plate1:1") = True And Component.IsActive("Plate2:1") = False
	Call oPlate1.CreateGeometryProxy(oPlate1.Definition.WorkPlanes.Item("Plate1_face_plane"), oPlaneProx1)
	oConstraint.ConvertToMateConstraint(oConstraint.EntityOne, oPlaneProx1, oConstraint.Offset.Value)
ElseIf Component.IsActive("Plate1:1") = False And Component.IsActive("Plate2:1") = True
	Call oPlate2.CreateGeometryProxy(oPlate2.Definition.WorkPlanes.Item("Plate2_face_plane"), oPlaneProx2)
	oConstraint.ConvertToMateConstraint(oConstraint.EntityOne, oPlaneProx2, oConstraint.Offset.Value)
Else
	Exit Sub
End If
oConstraint.Name = "Plate_Constraint"
ThisDoc.Document.Rebuild
	
	

See attached file 🙂

Message 6 of 9

jamieking89
Enthusiast
Enthusiast

Hi @JhoelForshav 

 

Thanks again, that is great. I am trying to expand my ilogic/coding skills with Inventor. This has helped me a great deal. I will have a play around with the slightly more complex version aswell and see how it works.

 

Thanks again, much appreciated!

 

Jamie

Message 7 of 9

MCADAEPFW
Enthusiast
Enthusiast

That's all fine and dandy but I want to specify a specific component in my assembly and then have it iterate through all the associated relationships and suppress them.   I can not find any documentation on how to set a specific component to do a 

 

   'For each joint attached to THIS SPECIFIC PART go through and suppress the joint if it is not already suppressed.' 

Also want to do the same thing with the constraints.   

 

i have ffound  code but nothing that says 'use this part' and suppress.  

 

0 Likes
Message 8 of 9

JhoelForshav
Mentor
Mentor

Hi @MCADAEPFW 

You want to pick the occurrence and all constraints/joints associated should be suppressed?

Dim oOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Pick component")
For Each oConstraint As AssemblyConstraint In oOcc.Constraints
oConstraint.Suppressed = True
Next
For Each oJoint As AssemblyJoint In oOcc.Joints
oJoint.Suppressed = True
Next

 

If this answer is not what you're looking for, start a new thread and we'll try to solve your problem there 🙂 This thread is already solved and your topic isn't really the same 🙂

Message 9 of 9

MCADAEPFW
Enthusiast
Enthusiast
While that code is what I am looking for I just what to be able to tell the code to use THIS part and suppress all it's constraints without any interaction from the user.
I've started a thread about this here: https://forums.autodesk.com/t5/inventor-customization/specify-part-specifically-and-suppress-constra...
0 Likes