CQ-editor icon indicating copy to clipboard operation
CQ-editor copied to clipboard

Object tree selection handling for non AIS_Shape objects

Open voneiden opened this issue 4 years ago • 0 comments

(Low priority issue)

Thanks for #317

A little bit more fine tuning is still required at https://github.com/CadQuery/CQ-editor/blob/0d091ba3d20114b4815f796ec48ab33f4ebbeb41/cq_editor/widgets/object_tree.py#L376

The statement works only for items of type AIS_Shape. To reproduce

  1. Show a scene with at least one AIS_Shape and one other AIS_InteractiveObject
  2. Click on the shape that is of type AIS_Shape
  3. Following output appears in console
ERROR: CQ-Editor: Uncaught exception occurred
Traceback (most recent call last):
  File "miniforge3/lib/python3.9/site-packages/cq_editor/widgets/object_tree.py", line 376, in handleGraphicalSelection
    if item.ais.Shape().IsEqual(shape):
AttributeError: 'OCP.AIS.AIS_MultipleConnectedInteractive' object has no attribute 'Shape'

Fragile point also here. The export context menu actions probably don't work for non-shapes?

https://github.com/CadQuery/CQ-editor/blob/0d091ba3d20114b4815f796ec48ab33f4ebbeb41/cq_editor/widgets/object_tree.py#L353


MWE

from cadquery import cq
from OCP.AIS import AIS_Line
from OCP.Geom import Geom_CartesianPoint

box = cq.Workplane().box(10, 10, 10)

line = AIS_Line(
    Geom_CartesianPoint(0, 0, 0),
    Geom_CartesianPoint(10, 10, 10)
)

show_object(box, 'box')
show_object(line, 'line')

Other direction seems to work fine (= if I select an AIS_MultipleConnectedInteractive from the tree, it gets highlighted in the viewer correctly)

voneiden avatar Feb 11 '22 19:02 voneiden