Delete Sick Joints / Constraint

Delete Sick Joints / Constraint

Alexrose1942
Advocate Advocate
1,085 Views
2 Replies
Message 1 of 3

Delete Sick Joints / Constraint

Alexrose1942
Advocate
Advocate

 Using this guy code http://inventortrenches.blogspot.co.il/2013/01/ilogic-delete-all-sick-assembly.html, im deleting sick constraint quickly. (Thank you Curtis) what will be the addition to the code so it works for "sick joints" the same way ?

 

Thanks 

Dim oAssDoc As AssemblyDocument
oAssDoc = ThisApplication.ActiveDocument
Dim oConstraint As AssemblyConstraint

RUSure = MessageBox.Show _
("Are you sure you want to Delete all sick constraints?",  _
"iLogic",MessageBoxButtons.YesNo)

If RUSure = vbNo Then
Return
Else
          i = 0
          For Each oConstraint In oAssDoc.ComponentDefinition.Constraints
            If oConstraint.HealthStatus <> oConstraint.HealthStatus.kUpToDateHealth And _
            oConstraint.HealthStatus <> oConstraint.HealthStatus.kSuppressedHealth Then
          oConstraint.Delete
            i = i + 1
          End If
          Next
End If
MessageBox.Show(" A total of "&  i & " constraints were deleted.", "iLogic")

 

 

 

 

Accepted solutions (1)
1,086 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi Alexrose1942,

 

Although I didn't test it much, I think this example will handle sick constraints and sick joints.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oAssDoc As AssemblyDocument
oAssDoc = ThisApplication.ActiveDocument

Dim oConstraint As AssemblyConstraint
Dim oJoint As AssemblyJoint

RUSure = MessageBox.Show _
("Are you sure you want to delete all sick Relationships?",  _
"iLogic",MessageBoxButtons.YesNo)

If RUSure = vbNo Then
Return
Else
          i = 0
          For Each oJoint In oAssDoc.ComponentDefinition.Joints
            If oJoint.HealthStatus <> oJoint.HealthStatus.kUpToDateHealth And _
            	oJoint.HealthStatus <> oJoint.HealthStatus.kSuppressedHealth Then
          		oJoint.Delete 
				i = i + 1
          	End If		  
          Next
		  
		  j = 0
          For Each oConstraint  In oAssDoc.ComponentDefinition.Constraints
            If oConstraint.HealthStatus <> oConstraint.HealthStatus.kUpToDateHealth And _
            	oConstraint.HealthStatus <> oConstraint.HealthStatus.kSuppressedHealth Then
          		oConstraint.Delete 
				j = j + 1
          	End If
          Next
End If
MessageBox.Show(" A total of "&  i+j & " Relationships were deleted.", "iLogic")

EESignature

Message 3 of 3

Alexrose1942
Advocate
Advocate

Seems like it's working,smileysurprised: 

can generally iLogic go deeper and search for those also in all subassemblies, I'm just asking as I'm very curious.

your code saved my day! 

 

Thanks 

0 Likes