How to use cadquery server ui import?

336 views Asked by At

I would like to experiment a bit with cadquery, it looks pretty cool! So, I installed the package using pip following the documentation (see https://cadquery.readthedocs.io/en/latest/installation.html). So far so good.

Next, I tried cadquery-server to render models (https://pypi.org/project/cadquery-server/). Installation is fine, server is up and running and accessible on default address.

Now, in the python script describing an example model, one should import the ui, by adding from cq_server.ui import ui, show_object at the begining of the script. Here I get into trouble, my IDE (VS code) complains that import "cq_server.ui" could not be resolved. Subsequently, the model is not rendered. I must be missing something obvious here... Any thoughts?

 import cadquery as cq
 from cq_server.ui import ui, show_object

 # These can be modified rather than hardcoding values for each dimension.
 length = 80.0  # Length of the block
 height = 60.0  # Height of the block
 thickness = 10.0  # Thickness of the block

 # Create a 3D block based on the dimension variables above.
 result = cq.Workplane("XY").box(length, height, thickness)

 # Displays the result of this script
 show_object(result)
1

There are 1 answers

1
Paul8043 On

I have seen the same problem. I could not get any help. However I found a solution that is even more pleasing. Try to use build123d together with vscode-ocp-cad-viewer, both available on GitHub. Read "readthedocs" of build123, go to the section "External Tools and Libraries", and there follow the instructions "see: ocp-vscode".