Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Hide and show sketches

erik
Advocate

Hide and show sketches

erik
Advocate
Advocate

Is there a function to hide and show a sketch by code?

I found a method on occurrences and BRepBodies named islightbulbon which does exactly what I want for those to types of objects, so I wondered why I couldn't find it for sketch. I mean, their structure seems pretty much the same when it comes to hiding and showing them.

 

Am I just blind or is it not there?

 

- Erik

0 Likes
Reply
Accepted solutions (1)
1,565 Views
4 Replies
Replies (4)

zhongyang.chenK3XZJ
Alumni
Alumni
Accepted solution

Hi,

 

You can try sketch.isVisible to hide/show a sketch.

Zhongyang Chen
Fusion 360 API Developer
1 Like

erik
Advocate
Advocate

Thank you, I thought it was a read-only property.

 

But I must say that this is the most inconsistent naming I have seen in Fusion. No offense.

 

Occurrence.isVisible is a read-only property.

Occurrence.isLightBulbOn is a read/write property.

Sketch.isVisible is a read/write property.

 

I get that there is a difference in being visible and having the light bulb turned on but it applies to both sketches, bodies and components. I don't see a reason why there should be a difference in the way they work.

 

And it is odd, that the API for Sketch.isVisible reads: "Indicates if this sketch is visible or not. Sketches that are not visible are ignored in profile calculations".

Only when one follows the link one will find that it is a read/write property.

Every time I find a read/write property in the Fusion API it sais "Gets and sets...".

 

- Erik

0 Likes

ekinsb
Alumni
Alumni

You're right that it is inconsistent.  The sketch design should be the same as the others.  I've logged it in our tracking system and will look at what needs to be done.  The most obvious thing is to add an isLightBulbOn property but the trick will be to not change the behavior of the isVisible property so we don't break any existing programs.  

 

Thanks for pointing out the problem.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

erik
Advocate
Advocate

I am happy to hear that I am not the only one finding it inconsistent.

I understand your concern about changing sketch to match components setup, but that would break the program I just wrote.

 

This is a tough decision to make but can you change it and then just try to spread the word as much as possible?

Thinking of future developers using these properties, they would probably run into the same problem.

 

If you dont change it to be a read-only property will you change the API in Sketch.isVisible to read something like: "Gets or sets if the Sketch is visible..."

 

- Erik

0 Likes