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: 

To toggle sketch dimension visibility using iLogic.

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
RoyWickrama_RWEI
1842 Views, 10 Replies

To toggle sketch dimension visibility using iLogic.

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.

10 REPLIES 10
Message 2 of 11
gavbath
in reply to: RoyWickrama_RWEI

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
in reply to: gavbath

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
2024.2
Please Accept as a solution / Kudos
Message 4 of 11
gavbath
in reply to: rhasell

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
in reply to: gavbath

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

Message 6 of 11
RoyWickrama_RWEI
in reply to: rhasell

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
in reply to: RoyWickrama_RWEI

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
in reply to: gavbath

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.

Message 9 of 11

For Each o3DSketch In oDoc.ComponentDefinition.Sketches3d
o3DSketch.Visible = False
o3DSketch.DimensionsVisible = False
Next
Message 10 of 11
rhasell
in reply to: gavbath

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
2024.2
Please Accept as a solution / Kudos
Message 11 of 11
RoyWickrama_RWEI
in reply to: rhasell

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

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

Post to forums  

Autodesk Design & Make Report