pyOCCT
pyOCCT copied to clipboard
Can't call AIS_InteractiveContext::EntityOwners method, no SelectMgr_IndexedMapOfOwner type
I cannot find a way to call the method AIS_InteractiveContext::EntityOwners. It requires an argument of type SelectMgr_IndexedMapOfOwner
which is not available through pyocct.
Any idea for a workaround to get the list of SelectMgr_EntityOwner
from AIS_InteractiveContext
or any over way to programmatically select subshapes of an AIS_Shape
?
Edit:
An alternative could have been SelectMgr_Selection::Entities, however the return type NCollection_Vector<Handle< SelectMgr_SensitiveEntity > >&
is not available through pyocct either.
Do you happen to have an example script that reproduces the issue using AIS_InteractiveContext::EntityOwners? I think I can bind the missing type, but would like a reproducible example to make sure and then add to the test suite. Thanks!
I sketched the following code using my current anaconda installation of pyocct.
from OCCT.AIS import AIS_Shape
from OCCT.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCCT.SelectMgr import SelectMgr_EntityOwner
from OCCT.TopAbs import TopAbs_EDGE
from OCCT.Visualization.QtViewer import ViewerQt
edge_mode = AIS_Shape.SelectionMode_(TopAbs_EDGE)
box = BRepPrimAPI_MakeBox(1, 1, 1).Shape()
viewer = ViewerQt()
ais_context = viewer._the_view.my_context
ais_shape = viewer.display_shape(box)
ais_context.Activate(ais_shape, edge_mode)
map_of_owner = SelectMgr_IndexedMapOfOwner() # not binded
owners = ais_context.EntityOwners(map_of_owner, ais_shape, edge_mode)
entyty_owner: SelectMgr_EntityOwner = map_of_owner.FindKey(1)
entyty_owner.SetSelected(True)
viewer.start()
In my understanding this snippet should create a box and select one of its edges.
Is this example ok or having it without the viewer (or else) would be of any help?