Dim oDoc As Inventor.Document
oDoc = ThisDoc.Document
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.Visible = True
Next
I use mostly the above iLogic (several forms of it) when creating sketches. Thanks - it is from one of this user group postings. However, I also would like to have the ability to toggle the sketch dimension visibility too. I request help. Thanks.
Solved! Go to Solution.
Solved by rhasell. Go to Solution.
Solved by gavbath. Go to Solution.
Solved by rhasell. Go to Solution.
I created a part for you, to demonstrate this working.
You were very close. You were looking for Sketch.DimensionsVisible
I used the API help in Inventor to find the relevant boolean for sketch dimension visibility.
Open the attached part, load the iLogic form, and toggle the checkbox to see the result.
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
Hi
Loved the concept, so I decided to use it as well, seeing as though sketch dimensions can sometimes get in the way.
Looking at your part it took me a while to figure out that Dimension visibility is in VBA.
I then Extracted it and placed it directly in iLogic, for future use in my environment.
This works a treat, thank you.
I will put a option in later when I get around to making it live.
Sub Main() Dim oDoc As Inventor.Document oDoc = ThisApplication.ActiveDocument Dim oSketch As Sketch For Each oSketch In oDoc.ComponentDefinition.Sketches 'oSketch.DimensionsVisible = False 'R.H - Test Visible = OFF oSketch.DimensionsVisible = True 'R.H - Test Visible = ON Next End Sub
In my example part, the VBA macro was just there for testing, you can delete it and the iLogic form will still work. It's just an iLogic form manipulating a True/False parameter that the iLogic rule uses to control the sketch dimension visibility
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
Hi Gavin,
Thanks for your reply. I have Inventor 2014 for which I could not open your model. Anyway, based on the 2nd posting (replying you by Rhasell), I got it doing it well for me.
Thanks a lot again.
Roy Wickrama
Hi Rhasell,
Thank you for the posting. I am getting it through - shown below is my sample run code.
Dim oDoc As Inventor.Document
Dim oSketch As Sketch
oDoc = ThisDoc.Document
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.Visible = True
oSketch.DimensionsVisible = False
Next
For Each oWorkplane In oDoc.ComponentDefinition.Workplanes
oWorkplane.Visible = False
Next
Best Regards.
No problem,
Don't forget that you can use True/False parameters to store the value so you can turn them on and off quickly with an iLogic form.
This was the code I wrote to do the above:
Dim oDoc As Inventor.Document
oDoc = ThisDoc.Document
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.DimensionsVisible = DimensionsVisible '<-- Here, "DimensionsVisible" is a True/False Parameter
Next
Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube
Thanks Gavin.
Great. I need this in all my sketches.
I sampled out it with the following.
Dim oDoc As Inventor.Document
oDoc = ThisDoc.Document
For Each oSketch In oDoc.ComponentDefinition.Sketches
oSketch.DimensionsVisible = 0
' oSketch.DimensionsVisible = 1
Next
Best Regards.
Gavin
I have finaly made my code live.
Probably a bit messy, but it all works well thanks.
One Question:
I have to press Apply before running the rule (Done/OK) (External Rule and External Form) Is there some code I can add to the following to bypass this?
'Definitions Dim oDoc As Inventor.Document Dim oSketch As Sketch oDoc = ThisDoc.Document 'Hide/show Dimensions For Each oSketch In oDoc.ComponentDefinition.Sketches oSketch.DimensionsVisible = Parameter("DIM_S") Next 'Hide/show Workplanes For Each oWorkplane In oDoc.ComponentDefinition.Workplanes oWorkplane.Visible = Parameter("WP_S") Next 'Hide/show WorkAxes For Each oWorkaxes In oDoc.ComponentDefinition.Workaxes oWorkaxes.Visible = Parameter("WA_S") Next 'Hide/show WorkPoints For Each oWorkpoints In oDoc.ComponentDefinition.Workpoints oWorkpoints.Visible = Parameter("WPT_S") Next 'Hide/show Sketched For Each oSketch In oDoc.ComponentDefinition.Sketches oSketch.Visible = Parameter("SKETCH_S") Next 'Hide/show 3D Geometry For Each o3DSketch In oDoc.ComponentDefinition.Sketches3d o3DSketch.Visible = Parameter("SKETCH3_S") o3DSketch.DimensionsVisible = Parameter("SKETCH3_S") Next