Thanks Brian.
that's just what I was looking for, I know it's a little dangerous to use,
but you know, sometimes there's a lot for sick constraints, and this routine
could save a lot of time.
By the way, I like to improve my programming skills on Inventor API, what
can you suggest on material/books/CD ect.
best regards,
Henrik
"Brian Ekins (Autodesk)" skrev i en meddelelse
news:5986616@discussion.autodesk.com...
Here's something I put together very quickly without much testing. It's an
interesting problem because as you delete constraints other constraints that
were previously ok can now become sick and others that were sick can become
healthy. This example goes through the assembly deleting all sick
constraints and continues to do this until no sick constraints remain.
Public Sub DeleteSickConstraints()
Dim bDeletedConstraints As Boolean
Do
Call DeleteSickConstraintsUtil(bDeletedConstraints)
Loop While bDeletedConstraints
End Sub
Public Sub DeleteSickConstraintsUtil(ByRef DeletedConstraints As Boolean)
DeletedConstraints = False
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
' Create a list of all the sick constraints in the assembly.
Dim colSickConstraints As New Collection
Dim oConstraint As AssemblyConstraint
For Each oConstraint In oAsmDoc.ComponentDefinition.Constraints
If oConstraint.HealthStatus <> kUpToDateHealth And
oConstraint.HealthStatus <> kSuppressedHealth Then
colSickConstraints.Add oConstraint
End If
Next
' Iterate through the sick constraints. Check each one
' to make sure it is still sick before deleting it because
' deleting another constraint could have made this one healthy.
For Each oConstraint In colSickConstraints
If oConstraint.HealthStatus <> kUpToDateHealth And
oConstraint.HealthStatus <> kSuppressedHealth Then
oConstraint.Delete
DeletedConstraints = True
End If
Next
End Sub
--
Brian Ekins
Autodesk Inventor API