CadQuery / CQ-editor

CadQuery GUI editor based on PyQT
Apache License 2.0
772 stars 119 forks source link

Use `show_object()` in the code sample #242

Open roipoussiere opened 3 years ago

roipoussiere commented 3 years ago

This is the default code sample when a user opens CQ-Editor for the first time:

import cadquery as cq
result = cq.Workplane("XY" ).box(3, 3, 0.5).edges("|Z").fillet(0.125)

show_object() is not used here so the fallback behavior is to render all object declared in variables. This can be a source of confusion for a beginner, who may think that there is no such function and the model to render must have to be declared as the result variable.

I suggest this (or similar):

import cadquery as cq

box = cq.Workplane("XY" ).box(3, 3, 0.5)
show_object(box.edges("|Z").fillet(0.125))
Jackbennett commented 2 years ago

In my opinion it would be better to explain what choices the editor is making by showing variables because I learned a lot experimenting in the tutorial by making a bunch of objects and toggling them on/off as they are listed on the right as a kind of "layers"

Using show_object loses the variable name and renders some magic number in the UI. It's also buried in the docs here? because users are in the cadquery docs site not the cq-editor readme once they're in the tutorial.

The blind auto-import from the widgets/debugger path is more magic for the user.

Should a user wish to take over rendering output that could be a separate tutorial.

Paul8043 commented 1 year ago

This can be a source of confusion for a beginner

The same applied to me. Sq-editor displays the model, even if there is no show_object()-call at all (in most cases, but not always). And during single-stepping the script, the behavior is even more confusing. It looks like the code is re-executed several times.