question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adam-urbanczykcommented, Nov 29, 2020

You can use debug instead of run and place a break point at the location of interest.

0reactions
GeorgesPaulcommented, Nov 29, 2020

Objects are rendered after the whole script is finished (show_object just adds them to a list).

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).

Moreover, the code is executed in the same thread as GUI.

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Am I able to wait until one object is destroyed until it creates ...
Actually you don't need to destroy and recreate the MOLE . You can just hide and show the same button in random position....
Read more >
Tracking multiple objects with OpenCV - PyImageSearch
This guide will teach you how to perform real-time multi-object tracking using OpenCV, Python, and the eight built-in object tracking ...
Read more >
Python sleep(): How to Add Time Delays to Your Code
In this example, you run main() and have it sleep for one second between two print() calls. In this code, you create a...
Read more >
Part 5. Sharing Data Between Callbacks - Dash Plotly
Dash is designed to work in multi-user environments where multiple people view the application at the same time and have independent sessions.
Read more >
ProcessPoolExecutor in Python: The Complete Guide
Future: Object returned when submitting tasks to the process pool that may complete later. Let's take a closer look at Executors, Futures, and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found