CadQuery / CQ-editor

CadQuery GUI editor based on PyQT
Apache License 2.0
777 stars 120 forks source link

cq-editor doesn't take in account show_object call from imported module #254

Open Jojain opened 3 years ago

Jojain commented 3 years ago

Hello, I have noticed that if I have in a file 'file1.py' a function like this this :

import cadquery as cq
def make_cylinder(radius):
    cyl = cq.Workplane().circle(5).extrude(10)
    try:
        show_object(cyl)
    except NameError:
        pass

And then in another file 'file2.py' I import this function :

import cadquery as cq
from file1 import make_cylinder
make_cylinder(5)

cq-editor won't render my cylinder, while if the function is in the main file it will render. Is there a way to make it work this way ?

Jojain commented 3 years ago

I just realized that it's actually because of the try/except, if I remove it I have a NameError while importing which make sense.

I suppose there is no way to have a show_object call in another file than the one that cq-editor runs then?

adam-urbanczyk commented 3 years ago

I could add show_object to builtins. Need to think though if it is a good idea.