Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remove all fixed constraints with iLogic

14 REPLIES 14
Reply
Message 1 of 15
ad64
3650 Views, 14 Replies

Remove all fixed constraints with iLogic

How does Inventor "Remove fix constraints" so quickly? Can this be replicated in iLogic?

 

The way I've previously done this requires looping through the constraint collection and deleting one at a time which may take a few minutes on a complex sketch, but when Inventor deletes fixed constraints throught the menu option it does it in a few seconds on the same sketch so Inventor must be able to select them all at once and delete them all at once. Is there a way to do this through the API or iLogic?

 

Thanks,

Steve

14 REPLIES 14
Message 2 of 15
cwhetten
in reply to: ad64

I've never heard of the "Remove Fix Constraints" command.  Where do you find it?

 

Cameron Whetten
Inventor 2014

Message 3 of 15
ad64
in reply to: cwhetten

In 2013, you select sketch geometry and right-click. It appears under the pop-up menu.

 

Steve

Message 4 of 15
cwhetten
in reply to: ad64

Sorry it took so long to get back to this.  Thanks for showing me that command, by the way.  I had never seen that before.

 

Below is an iLogic rule that might work.  I haven't actually tried it on a huge complex sketch.  I don't have any of those--it is best practice to keep your sketches as simple as possible.  But, it seems to work well on the sketches I tried.  Give it a try and see if it will do what you need.

 

Dim oSelectSet As SelectSet
oSelectSet = ThisDoc.Document.SelectSet
oSelectSet.Clear()

Dim oActiveEditObject As Object
oActiveEditObject = ThisApplication.ActiveEditObject

If oActiveEditObject.Type = ObjectTypeEnum.kPlanarSketchObject Then
    For Each entity As SketchEntity In oActiveEditObject.SketchEntities
       oSelectSet.Select(entity)
	Next
    ThisApplication.CommandManager.ControlDefinitions.Item("SketchUnfixCmd").Execute()
    oSelectSet.Clear()
Else
	MessageBox.Show("Activate a 2D sketch before running this rule.", "iLogic Rule: Remove Fix Constraints")

End If

 

I have also attached the rule in TXT format because sometimes copying and pasting iLogic code from the discussion board creates code problems.

 

Cameron Whetten
Inventor 2014

Please click "Accept as Solution" if this response answers your question.

Message 5 of 15
JDMather
in reply to: ad64


@ad64 wrote:

In 2013, you select sketch geometry and right-click. It appears under the pop-up menu.

 

Steve


That is interesting.  I guess because I (almost) never use Fixed Constraint (and certainly would not likely have more than one) I never knew that was there.


-----------------------------------------------------------------------------------------
Autodesk Inventor 2019 Certified Professional
Autodesk AutoCAD 2013 Certified Professional
Certified SolidWorks Professional


The CADWhisperer YouTube Channel


EESignature

Message 6 of 15
ad64
in reply to: JDMather

I don't use the fixed command either in regular modelling, but this was for my Sketch Repair Tool: http://forums.autodesk.com/t5/Autodesk-Inventor/Sketch-Repair-amp-Enhancement-Tool-written-in-iLogic...

 

When the Sketch Repair Tool auto-constrains tangent lines and curves or synchronizes the radii in a sketch it needs to ground all of the straight lines so that the actual shape and size of the profile is not altered. This command is commonly used to auto-constrain geometry brought in from AutoCAD but is also useful when repairing poorly constrained Inventor sketches.

 

Currently the code in the Sketch Repair Tool loops through all of the geometry searching for fixed constraints to remove them at the end of the routine, but I am looking for a way to expedite it by removing them all at once like Inventor does.

 

I'm going to test out Cameron's code above and see if it improves performance. Thanks for the idea, Cameron.

 

Steve

Message 7 of 15
JDMather
in reply to: ad64

Can you check the url?  I think it is broken.  I would like to check out your Sketch Repair Tool.

Never mind - I found it.


-----------------------------------------------------------------------------------------
Autodesk Inventor 2019 Certified Professional
Autodesk AutoCAD 2013 Certified Professional
Certified SolidWorks Professional


The CADWhisperer YouTube Channel


EESignature

Message 8 of 15
ad64
in reply to: JDMather

I've edited the above post to repair the link. It should be working now.

 

If the link is still broken, you might try searching the forum for the thread: "Sketch Repair & Enhancement Tool written in iLogic."

 

Steve

Message 9 of 15
ad64
in reply to: cwhetten

Cameron's code is significantly faster, but I notice that it still selects entities one at a time. Is there anyway to "select all"?

 

What I've tried:

- selecting  the entities all at once - oSelectSet.SelectMultiple(oSketch.SketchEntities) / oSelectSet.SelectMultiple(oSketch.SketchLines). It errored out.

- selecting the sketch as a whole - oSelectSet.Select(oSketcht) - which it successfully did but the command to unground did not do anything.

 

Are there any other suggestions.


Steve

 

 

Message 10 of 15
Carthik_Babu
in reply to: cwhetten

Dear Sir,
Can you message the collection of command that can be executed by
CommandManager.ControlDefinitions.Item(?????)
Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 11 of 15
cwhetten
in reply to: Carthik_Babu

The Mod the Machine blog is an excellent resource for learning how to program in Inventor.  The following links to an article that describes how to get a list of commands to call from the CommandManager:

 

http://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html

 

I used their little program to get the list that is attached.  This list is from Inventor 2014, so it may be slightly different than what you have in 2011.  You may want to run the little program to get a list for your version.

 

Cameron Whetten
Inventor 2014

Message 12 of 15
ad64
in reply to: Carthik_Babu

Using EventWatcher I obtained the command name:

 

ThisApplication.CommandManager.ControlDefinitions.Item("SketchUnfixCmd").execute

 

However, I still have the same problem as before: I am unable to automatically select all the geometry at once.
If I select the entire sketch as a whole Inventor sees this as only one entity and does not remove the constraints from the individual items. I have not been able to add the SketchEntities en masse to the select set.

 

Dim oSketch As Sketch = ThisApplication.ActiveEditObject 'Current Sketch
Dim oSelectSet As SelectSet = ThisDoc.Document.SelectSet
oSelectSet.Select(oSketch)
ThisApplication.CommandManager.ControlDefinitions.Item("SketchUnfixCmd").execute

Any ideas on how to select all the sketch entities at once (or even all of the sketch lines at once) without user intervention?

 

Thanks,

Steve

Message 13 of 15
Carthik_Babu
in reply to: ad64

check out the below code & link....hope it will be useful.....

 

http://forums.autodesk.com/t5/Inventor-Customization/wanted-macro-to-delete-unresolved-sketch-items/...

 

Sub deleteconstraints()
Dim oPartDoc As PartDocument
Dim oSketch As PlanarSketch

Dim geoconstraint As GeometricConstraint

On Error Resume Next

Set oPartDoc = ThisApplication.ActiveDocument

For Each oSketch In oPartDoc.ComponentDefinition.Sketches
For Each geoconstraint In oSketch.GeometricConstraints
Call geoconstraint.Delete
Next geoconstraint

Next oSketch

MsgBox( "All constraints deleted!")
End Sub

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 14 of 15
ad64
in reply to: Carthik_Babu

Carthik,

 

The method you suggest is what I originally had, but it is much slower than triggering Inventor's built-in "Remove all Fixed Constraints" command.
The only obstacle to using the faster command is finding a way to select all of the sketch geometry so that I can run it. The user can easily do this with his mouse, but it is not as easy to get Inventor to automatically do it.

 

Steve

Message 15 of 15
RoyWickrama_RWEI
in reply to: cwhetten

I like this because some times I apply fixed constraints on some of the sketch member when I paste some AutoCAD sketches on the Inventor model sketch. This is helping me to remove them back. Thanks.

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

Post to forums  

Autodesk Design & Make Report