diff --git a/src/ifcopenshell-python/ifcopenshell/geom/app.py b/src/ifcopenshell-python/ifcopenshell/geom/app.py index d6bab207f1..03d7ac477a 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/app.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/app.py @@ -463,7 +463,6 @@ class application(QtWidgets.QApplication): qtViewer3d.__init__(self, widget) self.ais_to_product = {} self.product_to_ais = {} - self.counter = 0 self.window = widget self.thread = None @@ -488,11 +487,11 @@ class application(QtWidgets.QApplication): ais = display_shape(shape, viewer_handle=v) product = f[shape.data.id] - if USE_OCCT_HANDLE: - ais.GetObject().SetSelectionPriority(self.counter) - self.ais_to_product[self.counter] = product + # Keyed by the AIS object itself (its __eq__/__hash__ track the + # underlying OCCT instance) instead of AIS_InteractiveObject.SetSelectionPriority(), + # which no longer exists on general AIS objects in modern pythonocc-core (#1098). + self.ais_to_product[ais] = product self.product_to_ais[product] = ais - self.counter += 1 QtWidgets.QApplication.processEvents() @@ -573,8 +572,9 @@ class application(QtWidgets.QApplication): v.InitSelected() if v.MoreSelected(): ais = v.SelectedInteractive() - inst = self.ais_to_product[ais.GetObject().SelectionPriority()] - self.instanceSelected.emit(inst) + inst = self.ais_to_product.get(ais) + if inst is not None: + self.instanceSelected.emit(inst) class window(QtWidgets.QMainWindow): diff --git a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py index 15a4dfc838..c5ebdf7ad6 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/occ_utils.py @@ -225,7 +225,11 @@ def display_shape(shape, clr=None, viewer_handle=None): def set_shape_transparency(ais, t, update_viewer=True): - handle.Context.SetTransparency(ais, t, update_viewer) + # AIS_InteractiveContext.SetTransparency()'s argument count differs across + # pythonocc-core versions (#1037); AIS_InteractiveObject.SetTransparency() is stable. + ais.SetTransparency(t) + if update_viewer: + handle.Context.UpdateCurrentViewer() def get_bounding_box_center(bbox):