Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete all errors on constrains in Design Doctor

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1077 Views, 5 Replies

Delete all errors on constrains in Design Doctor

I look for some inspiration til write a routine that can delete all
constrains witch give an error. Wheen I work on iam, and make som changes,
the design doctor giv me list off errors for constrains, a routeine to
clear that list would be a great program, for sometime I have 5-10-20,
constrains, and I find it easyer to deleete than find the problem.Bbut I
can't aw way to get to that information.

thanks

Henrik
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

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
Message 3 of 6
Anonymous
in reply to: Anonymous

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
Message 4 of 6
Anonymous
in reply to: Anonymous

To be safer, you COULD modify to only SUPPRESS the sick constraints!
Should still do the job.

Henrik Villars wrote:
> Thanks Brian.
> that's just what I was looking for, I know it's a little dangerous to use,
Message 5 of 6
Anonymous
in reply to: Anonymous

There are a few existing resources. the primary resource is the programming
help delivered with Inventor. There are some overview topics, sample
programs, and more detailed information about all of the API functions.
Another resource is the website www.autodesk.com/developinventor. Another
one is this newsgroup. There are some other websites hosted by Inventor
users that have some API information. Also keep a watch out for a new
Inventor API related blog that will be starting up in the next few weeks.
I'll post a notice here when it goes live.
--
Brian Ekins
Autodesk Inventor API
Message 6 of 6
Anonymous
in reply to: Anonymous

http://discussion.autodesk.com/thread.jspa?messageID=5463410

is good

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report