To toggle sketch dimension visibility using iLogic.

To toggle sketch dimension visibility using iLogic.

RoyWickrama_RWEI
Advisor Advisor
2,169 Views
10 Replies
Message 1 of 11

To toggle sketch dimension visibility using iLogic.

RoyWickrama_RWEI
Advisor
Advisor

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.

0 Likes
Accepted solutions (3)
2,170 Views
10 Replies
Replies (10)
Message 2 of 11

gavbath
Collaborator
Collaborator

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


   

Message 3 of 11

rhasell
Advisor
Advisor
Accepted solution

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

 

Reg
2026.1
Message 4 of 11

gavbath
Collaborator
Collaborator
Accepted solution

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


   

Message 5 of 11

RoyWickrama_RWEI
Advisor
Advisor

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

0 Likes
Message 6 of 11

RoyWickrama_RWEI
Advisor
Advisor

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.

Message 7 of 11

gavbath
Collaborator
Collaborator

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


   

Message 8 of 11

RoyWickrama_RWEI
Advisor
Advisor

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.

0 Likes
Message 9 of 11

RoyWickrama_RWEI
Advisor
Advisor
For Each o3DSketch In oDoc.ComponentDefinition.Sketches3d
o3DSketch.Visible = False
o3DSketch.DimensionsVisible = False
Next
0 Likes
Message 10 of 11

rhasell
Advisor
Advisor
Accepted solution

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?

 

form-true false.JPG

 

 

 

'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

 

Reg
2026.1
Message 11 of 11

RoyWickrama_RWEI
Advisor
Advisor
Sorry, I took so long to accept your post as a solution.