How to identify the parameter associated with a constraint

How to identify the parameter associated with a constraint

duke
Enthusiast Enthusiast
317 Views
2 Replies
Message 1 of 3

How to identify the parameter associated with a constraint

duke
Enthusiast
Enthusiast

I have written logic that gets a constraint that I want to change the associated dimension of. I am able to find the constraint and the name of the constraint, but I haven't been able to determine how to link the constraint to the parameter that stores the dimension value. What am I missing? 

 

I can see in the Parameters menu that the parameter name is "d1", and that it is consumed by constraint "mate:1", but iLogic seems to act like there is no reasonable bridge linking the parameter and the constraint.

 

Dim oAssemDoc As AssemblyDocument
oAssemDoc = ThisApplication.ActiveDocument

Dim oConstraints As AssemblyConstraints
oConstraints = oAssemDoc.ComponentDefinition.Constraints

Dim oOcc As ComponentOccurrence
oOcc = oAssemDoc.ComponentDefinition.Occurrences(2)

Dim compConstraints As AssemblyConstraintsEnumerator
compConstraints = oOcc.Constraints

Dim oConstraint As AssemblyConstraint
oConstraint = compConstraints.Item(1)

logger.Info(oConstraint.Name)

Dim oParams As Parameters
oParams = oAssemDoc.ComponentDefinition.Parameters.ModelParameters

For Each oParam As ModelParameter In oParams
	'Something like If oParam.consumedBy = oConstraint.Name
	'	oParam.Value = 10 in
	'End If
Next 

 

0 Likes
Accepted solutions (1)
318 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

Every assembly constraint contains reference to its parameter, but how to access them depends on constraint type. You can see API reference or you can use tools such as VBA Object Browser for Inventor to find the appropriate property of constraint you want.

Sample for MateConstraint and InsertConstraint

MichaelNavara_0-1726206611083.png  

MichaelNavara_1-1726206673276.png

 

 

0 Likes
Message 3 of 3

duke
Enthusiast
Enthusiast
Thank you! It seems that I was looking in the right place, but I did not realize that every constraint type had to be individually declared in order to access its parameters. I was able to get the program working after following your tip and declaring the specific constraint type.
0 Likes