Find broken constraints

Find broken constraints

ndillner343SKL
Enthusiast Enthusiast
429 Views
4 Replies
Message 1 of 5

Find broken constraints

ndillner343SKL
Enthusiast
Enthusiast

Hello, is it possible to find and identify which constraints are broken within an assembly? 

 

	Dim oAsm As AssemblyDocument = ThisDoc.Document
	Dim oConstraint As AssemblyConstraint = oAsm.ComponentDefinition.Constraints.Item("Flush:5") 'Name of constraint
	Dim oOcc2 As ComponentOccurrence = oConstraint.AffectedOccurrenceTwo
	Dim oOccDoc As Document = oOcc2.Definition.Document
	
	iLogicVb.Automation.GetNamedEntities(oOccDoc).GetName(oConstraint.EntityTwo.NativeObject)
	Dim Msg As String = "Entity 2 Name: " & iLogicVb.Automation.GetNamedEntities(oOccDoc).GetName(oConstraint.EntityTwo.NativeObject) & "Offset parameter: " & oConstraint.Offset.Name
	MsgBox(Msg)
0 Likes
Accepted solutions (1)
430 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor
Accepted solution

At the beginning you can try this code snippet.

It prints all constraint with HealthStatus different from kUpToDateHealth

 

Dim asm As AssemblyDocument = ThisDoc.Document

For Each c As AssemblyConstraint In asm.ComponentDefinition.Constraints
	If c.HealthStatus <> HealthStatusEnum.kUpToDateHealth Then
		Logger.Warn("Invalid contraint: {1}{0}Occurrences:{0}{2}{0}{3}", vbCrLf, c.Name, c.OccurrenceOne.Name, c.OccurrenceTwo.Name)
	End If
Next

 

0 Likes
Message 3 of 5

ndillner343SKL
Enthusiast
Enthusiast

Thank you @Michael.Navara! This will really help me get started. Where can I find a list of variables for assemblies? "HealthStatus" for example. I had no Idea this variable existed. 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

HealthStatusEnum (Link1, Link2)

 

...to find this, and more, go to your online help web page:

https://help.autodesk.com/view/INVNTOR/2022/ENU 

Then follow below visual categories

WCrihfield_0-1664808404847.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

Michael.Navara
Advisor
Advisor

Usually I use my tool: VBA Object Browser for Inventor

And also API Help for Inventor as @WCrihfield mentions above is very usefull

MichaelNavara_0-1664808962860.png