How do change the Maximum Limit of Angle constarint using ILogic

How do change the Maximum Limit of Angle constarint using ILogic

Anonymous
Not applicable
948 Views
6 Replies
Message 1 of 7

How do change the Maximum Limit of Angle constarint using ILogic

Anonymous
Not applicable

Hi All,
I'm Working on creating Angle constraint by using ILogic. I'm using below functional code to create new Angle constraint. I want to change the maximum limit once the angle constraint got created. Please give your suggestions.

Existing Function code I'm Using now:

oAxis1 = oAsmCompDef.WorkAxes.Item ("Y Axis")
oAxis2 = comp.Definition.WorkAxes("Y Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
If Not ConstraintExists(comp, ObjectTypeEnum.kAngleConstraintObject, oproxyAxis2, oAxis1) Then

oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0, 78594)
'78594 refers to the undirected angle constraint solution type. 78593 refers to
'directed (which is default), and 78595 is the referenced vector solution
oAConstraint.ConstraintLimits.MaximumEnabled = True
oAConstraint.ConstraintLimits.Maximum.Expression = "45 deg"
oAConstraint.ConstraintLimits.MinimumEnabled = True
oAConstraint.ConstraintLimits.Minimum.Expression = "0 deg"
If oAConstraint.HealthStatus = oAConstraint.HealthStatus.kInconsistentHealth Then
oAConstraint.Delete
oAxis1 = oAsmCompDef.WorkAxes.Item("Y Axis")
oAxis2 = comp.Definition.WorkAxes("Z Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
If Not ConstraintExists(comp, ObjectTypeEnum.kAngleConstraintObject, oproxyAxis2, oAxis1) Then
oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0, 78594)
'78594 refers to the undirected angle constraint solution type. 78593 refers to
'directed (which is default), and 78595 is the referenced vector solution
oAConstraint.ConstraintLimits.MaximumEnabled = True
oAConstraint.ConstraintLimits.Maximum.Expression = "45 deg"
oAConstraint.ConstraintLimits.MinimumEnabled = True
oAConstraint.ConstraintLimits.Minimum.Expression = "0 deg"
If oAConstraint.HealthStatus = oAConstraint.HealthStatus.kInconsistentHealth Then
oAConstraint.Delete
oAxis1 = oAsmCompDef.WorkAxes.Item("Y Axis")
oAxis2 = comp.Definition.WorkAxes("X Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
If Not ConstraintExists(comp, ObjectTypeEnum.kAngleConstraintObject, oproxyAxis2, oAxis1) Then
oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0, 78594)
'78594 refers to the undirected angle constraint solution type. 78593 refers to
'directed (which is default), and 78595 is the referenced vector solution
oAConstraint.ConstraintLimits.MaximumEnabled = True
oAConstraint.ConstraintLimits.Maximum.Expression = "45 deg"
oAConstraint.ConstraintLimits.MinimumEnabled = True
oAConstraint.ConstraintLimits.Minimum.Expression = "0 deg"

Thanks & Regards,
Manoj Sampath

0 Likes
Accepted solutions (1)
949 Views
6 Replies
Replies (6)
Message 2 of 7

JaneFan
Autodesk
Autodesk

Hi @Anonymous , 

 

The way you are using to set constraint limit is correct, would you please describe what error you are meeting using the code? 

oAxis1 = oAsmCompDef.WorkAxes.Item("Y Axis")
oAxis2 = oAsmCompDef.WorkAxes("Y Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)

If Not ConstraintExists(comp, ObjectTypeEnum.kAngleConstraintObject, oproxyAxis2, oAxis1) Then

	oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0,Inventor.AngleConstraintSolutionTypeEnum.kDirectedSolution )
	
	'78594 refers to the undirected angle constraint solution type. 78593 refers to
	'directed (which is default), and 78595 is the referenced vector solution
	oAConstraint.ConstraintLimits.MaximumEnabled = True
	oAConstraint.ConstraintLimits.Maximum.Expression = "45 deg"
	oAConstraint.ConstraintLimits.MinimumEnabled = True
	oAConstraint.ConstraintLimits.Minimum.Expression = "0 deg"
End If 
If oAConstraint.HealthStatus = oAConstraint.HealthStatus.kInconsistentHealth Then
	oAConstraint.Delete
	oAxis1 = oAsmCompDef.WorkAxes.Item("Y Axis")
	oAxis2 = comp.Definition.WorkAxes("Z Axis")
	comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
End If 



Jane Fan
Inventor/Fusion QA Engineer
Message 3 of 7

Anonymous
Not applicable

@JaneFan 

 

Hi Jane,

I'm not facing any error in this code, Angle constraint creating successfully.

But once the constraint created I want to change the Maximum limit to 0 DEG.

 

I can change the Maximum Limit to 0 DEG on existing function code, but Inventor taking wrong working Axis and creating Angle constraint, To avoid this first I want to give Maximum limit as 45DEG and I want to change that to

0 DEG once the constraint got created. Is it possible?

 

Thanks & Regards,

Manoj Sampath

0 Likes
Message 4 of 7

JaneFan
Autodesk
Autodesk

@Anonymous , 

I don't know why it is taking the wrong axis if you set maximum limit to 0 when creating constraint, but it is ok to set constraint limit after creation, as long as making sure the angle value is between minimum limit and maximum limit. 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 5 of 7

Anonymous
Not applicable

@JaneFan 

Hi Jane,

I have attached the presentation to explain why I don't want to set 0 DEG as maximum limit initially.

Please check and  let me know if you need any Clarifications.

As well as Can you suggest some Functional code to change the Maximum Limit after the constraint creation.

Thanks & Regards,

Manoj Sampath 

0 Likes
Message 6 of 7

MjDeck
Autodesk
Autodesk
Accepted solution

@Anonymous , please try this code to set the Maximum to 45 and then back to zero:

oAConstraint.ConstraintLimits.MaximumEnabled = True
oAConstraint.ConstraintLimits.Maximum.Expression = "45 deg"
oAConstraint.ConstraintLimits.MinimumEnabled = True
oAConstraint.ConstraintLimits.Minimum.Expression = "0 deg"
oAConstraint.ConstraintLimits.MaximumEnabled = False
oAConstraint.ConstraintLimits.Maximum.Expression = "0 deg"
oAConstraint.ConstraintLimits.MaximumEnabled = True

If you can post a sample assembly, we might be able to suggest an easier way to constrain your parts.
In STEP 01 on your pptx, you say that the choke is assembled to the value using "Mate & Insert option". Are you using two separate constraints to do this, or only one?


Mike Deck
Software Developer
Autodesk, Inc.

Message 7 of 7

Anonymous
Not applicable

Hi@MjDeck 

 

The Function code you have provided is working fine.

 

Thanks & Regards,

Manoj Sampath

0 Likes