CQ-editor icon indicating copy to clipboard operation
CQ-editor copied to clipboard

API - Is there any way to hide an object in CadQuery?

Open skanga opened this issue 5 years ago • 6 comments

Analogous to show_object(result) is there something like hide_object(result) - if not can we make that an enhancement request?

skanga avatar Oct 19 '20 18:10 skanga

If you don't call show_object on an object it will be not shown. Why would you need a separate hide_object call?

adam-urbanczyk avatar Oct 20 '20 06:10 adam-urbanczyk

I think this may be related to how CQ-editor magically finds and displays Workplane objects by default. For instance, the following script will implicitly display the box in CQ-editor.

import cadquery as cq
result = cq.Workplane().box(1, 1, 1)

I'm not familiar with any option to turn that off, so if you don't want the model to display for some reason you're kind of stuck.

jmwright avatar Oct 20 '20 12:10 jmwright

You can always use del. I'll wait for a clarification from the OP.

adam-urbanczyk avatar Oct 20 '20 19:10 adam-urbanczyk

If you don't call show_object on an object it will be not shown. Why would you need a separate hide_object call?

I thought about trying to animate an object. I figured (perhaps naively) that a loop of

show_object() hide_object() translate_object()

would animate things nicely and wanted to try it out (maybe it would not work or be fast enough, etc)

skanga avatar Oct 21 '20 05:10 skanga

Code execution is blocking and I don't think this will change anytime soon. Out of curiosity: what is the use case that you have?

Similar feature request here: https://github.com/CadQuery/CQ-editor/issues/60

adam-urbanczyk avatar Oct 22 '20 17:10 adam-urbanczyk

Thanks @adam-urbanczyk - my use case is similar to issue: #60 I'm trying to to show a door open/close.

skanga avatar Oct 28 '20 03:10 skanga

Dear all,

I encountered a similar problem: I have some objects which I assemble to a big one, but some of the objects are to be cut out instead of added. When I run the code, the GUI always shows ALL objects and I have to deselect all cut objects in order to see the result clearly.

I could not find a way to unselect or hide by python command. The only way for me was to delete the variables which hold the cut objects after the cut has been employed to the result object. I am adding this here, because the search for "cadquery hide object" brings you to this thread and for me it did the trick of "hiding" the object.

subobject = whatever result = result.cut(subobject) del subobject show_object(result)

Your idea with showing animation won't work, because you would not see the intermediate results during execution of the script as has been said above.

Ruebenschus avatar Oct 17 '22 12:10 Ruebenschus

Hi, same here. Could it be an option to implement a switch where user can decide generally if all object are visible by default or nothing is visible until 'show_object()' is coded for the specific object?

sorry, unfortunatelly this is beyond my coding skill...

Thank you, Markus

mukral avatar Jan 25 '23 12:01 mukral

That is the current behavior with calling show_object explicitly. It is not necessary to call del with show_object.

adam-urbanczyk avatar Jan 25 '23 15:01 adam-urbanczyk