Multiple show_object(shape) followed by time.sleep(2) don't work?
See original GitHub issue// edit: fixed problem description.
The code that is problematic / not intuitive:
import time
res1 = cq.Workplane().box(1,1,1)
show_object(res1)
time.sleep(2)
res2 = cq.Workplane().sphere(2)
show_object(res2)
time.sleep(2)
res3 = cq.Workplane().box(3,3,3)
show_object(res3)
time.sleep(2)
res4 = cq.Workplane().sphere(4)
show_object(res4)
I would expect the above code to render a small cube and then render the larger sphere, then a box inside that sphere (sphere sticks out of the box), then a larger sphere that covers everything. Each step with a 2 second break after rendering. This doesn’t work as expected.
The reason why this doesn’t work as I expected has been explained by adam-urbanczyk:
Objects are rendered after the whole script is finished (show_object just adds them to a list).
It would be cool if in the future there would be a way to see how objects are built up by the script step by step. It could give a quick intuitive insight into how the script works. Especially when scripts are large and complex (and made by other people). It would be nice if this could be setup in the script itself by the programmer.
A workaround to do this now is to manually set breakpoints in CQ-editor, press the “Debug” button and then the “continue” button every time you want to go to the next breakpoint. This way you can see how the model is being built up.
Note: there’s a “clear all before each run” option in CQ-editor, which should be enabled (to avoid larger previously rendered objects to be in the way of smaller newly rendered objects).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
You can use
debug
instead ofrun
and place a break point at the location of interest.Ok, that’s not what I would expect personally from a call that’s named “show_object” (I would expect it to show the object right then and there as the name implies).
Ok, this explains why I had a feeling that the sleep() calls where sometimes working and sometimes not working.
I’ll try to edit my post again to reflect this. Thanks for the clarification!