In SDK, how do I see if geometry is currently hidden?

export

#1

When exporting in my C++ plug-in, I want to give the user the option of exporting all the geometry or only the currently visible geometry, but I’m not seeing how I can get that information via the API.

Any suggestions?


#2

As you traverse the model you need to check two things, the visibility property of the drawingelement and the visibility of the layer it is on.

SUDrawingElementGetHidden
http://extensions.sketchup.com/developer_center/sketchup_c_api/sketchup/drawing__element_8h.html#a79d3a91422578b3de68291d52a659055

SULayerGetVisibility http://extensions.sketchup.com/developer_center/sketchup_c_api/sketchup/layer_8h.html#aba483bf96144ce009319f6f8c7ee2e16

Note that both of these properties are local to that entity/layer - they don’t keep track of the visibility of the parent containers.


#3

Ah, interesting. I have not had occasion to use the SUDrawingElementRef in my code yet. I think that’s probably exactly what I want. Will report back when/if I get it working.


#4

Yea, the docs aren’t great at conveying the class hierarchy at a glance.

The gist is that most things inherit from Entity. The C API functions is currently for attributes.

DrawingElement (inherit from Entity) is further specialisation which most things visible in the viewport inherit from, edges, faces, groups etc. This one got a few more general functions.

Then you have stuff like Layers, Materials, Pages and Vertices, they inherit directly Entity - because you don’t draw or manipulate them in the viewport.


#5

I used SUDrawingElementGetHidden, and this works fine for some models.

For few models, this doesn’t work.
I opened the model in sketchup and toggeled Edit->HiddenGeometry. I could see the hidden geometry on/off.
But when i use SUDrawingElementGetHidden API and hide the geometry, it still shows the hidden geometry.

So, I want to know if I am missing anything. Is there any other check i need to do other than SUDrawingElementGetHidden?


#6

SUDrawingElementGetHidden only returns the boolean state of the Visible property of the entity.
If you need to determine if the user sees the entity in the model you need to combine that, with the visibility state of it’s layer - as well as its parents. Then finally the “View > Hidden Geometry” which is a model wide state you obtain from the rendering options (via the "DrawHidden" key I think).


#7

the api

@thomthom give you the right api
but it may not act like what you are expecting.
The attribute of an object is different from what it looks like. for example, a component is not hidden,but all faces in this component is hidden. then, you may export an empty component(if you pass hidden items).