Open
Description
Dear community,
I want to assign a unique ID to an AIS_Shape and have therefore created the subclass My_AIS_Shape:
class My_AIS_Shape(AIS_Shape):
def __init__(self, shape: TopoDS_Shape, id: str):
super().__init__(shape)
self.ID = id
...
ais_context = display.GetContext()
new_aisshape = My_AIS_Shape(topodsshape, "newid")
ais_context.Display(new_aisshape, True)
new_gpTrsf = gp_Trsf(...)
ais_context.SetLocation(new_aisshape, TopLoc_Location(new_gpTrsf))
display.View.Redraw()
There is no problem assigning an instance of this class to the AIS_Context and manipulating it via the AIS_Context. My goal now is to use the "mouse picking logic" functions of the AIS_Context:
ais_context.MoveTo(100, 100, display.View, True)
has_detected = ais_context.HasDetected()
if has_detected:
ais_detected = ais_context.DetectedInteractive()
print("AIS_Shape with ID:", ais_detected.ID) # ID from class My_AIS_Shape
The problem now is that ais_context.DetectedInteractive() returns an AIS_InteractiveObject whose class is AIS_Shape and not My_AIS_Shape as hoped.
ais_detected.IsInstance("AIS_Shape") -> True
ais_detected.IsInstance("My_AIS_Shape") -> False
How can I solve this problem and get an object of my own class back from ais_context.DetectedInteractive() to access the ID attribute?
Thank you very much in advance for tips and help,
best regards
Michael