bernhard-42 / vscode-ocp-cad-viewer

A viewer for OCP based Code-CAD (CadQuery, build123d) integrated into VS Code
Apache License 2.0
78 stars 9 forks source link

Add a parameter to suppress show sketch_local #59

Closed bernhard-42 closed 3 months ago

bernhard-42 commented 4 months ago

Jern's approach:

classes = (BuildPart, BuildSketch, BuildLine)  # for OCP-vscode
variables, s_o, s_n, slocal = (list(cf().f_locals.items()), [], [], False)
for name, obj in variables:
    if (
        isinstance(obj, classes)
        and not name.startswith("_")
        and not name.startswith("obj")
    ):
        if obj._obj_name != "sketch" or slocal:
            s_o.append(obj), s_n.append(f"{name}.{obj._obj_name}")
        elif obj._obj_name == "sketch":
            s_o.append(obj.sketch), s_n.append(f"{name}.{obj._obj_name}")
show(
    *s_o,
    # ,
    names=s_n,
    reset_camera=Camera.KEEP,
)
jdegenstein commented 4 months ago

missing import statement for the above:

from inspect import currentframe as cf
bernhard-42 commented 3 months ago

fixed in 2.2.2