You sometimes end up with a large number of broken (sick) assembly constraints, due to a particular workflow (such as swapping out a base component). You know why this is happening and don't mind fixing the assembly, but you wish there was a way to delete all of the sick assembly constraints at once, so you can re-constrain the assembly without having to be bothered by the alerts.
Solution:
Here is a quick iLogic snippet to help with this:
* A special thanks to Brendan Henderson for letting me know about a coding error I had when I first posted this. Check out Brendan's own blog at: http://www.blh.com.au/#/blog/4572268941
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")