Selection
Object selection
Inside an interactor PythonPart it's possible to start the standard Allplan selection interactor. This can be done as follows:
post_element_selection = AllplanIFW.PostElementSelection()
AllplanIFW.InputFunctionStarter.StartElementSelect("Select the objects",
sel_setting,
post_element_selection,
True)
After this call it's possible to use the entire Allplan selection functionalities such as selecting via point or area as well as setting filters for the selection of the required objects. In addition to the standard Allplan filters it's possible to start this selection interactor with a defined filter.
Face selection
Inside an interactor PythonPart it's possible to select the face of an object. The selection can be executed by using the member functions of the class FaceSelectService.
In the first step, a face object needs to be selected:
self.coord_input.SelectElement(mouseMsg= mouse_msg,
pnt= pnt,
pMsgInfo= msg_info,
bHighlight= True, #(1)!
bSelAlways= True,
bAllowCenter= True,
selectSetting= self.sel_setting)
polyhedron_ele = coord_input.GetSelectedElement()
if polyhedron_ele.IsNull():
return True
- This will highlight the selected element in blue.
Polyhedron face selection
Any object with a polyhedron geometry can be selected as a face object. After the face object has been selected, the face selection is confirmed by:
is_selected, face_polygon, intersect_result = \
AllplanBaseEle.FaceSelectService.SelectPolyhedronFace(\
polyhedron= polyhedron_ele,
pnt= pnt,
highlightFace= True, #(1)!
viewProj= self.coord_input.GetViewWorldProjection(),
doc= self.coord_input.GetInputViewDocument(),
includeUVSSelection= True #(2)!
)
-
Setting this argument to True will result in the selected face being highlighted in red
-
If this argument is set to True, the face selection can also be performed within a UVS.
Example
For a complete usage of SelectPolyhedronFace, see the example PolyhedronFaceSelection located in
- …\etc\Examples\PythonParts\ModelObjectExamples\SelectionExamples\PolyhedronFaceSelection.pyp
- …\etc\PythonPartsExampleScripts\ModelObjectExamples\SelectionExamples\PolyhedronFaceSelection.py
Wall face selection
The selection of wall faces is similar to the selection of polyhedron faces but limited to wall objects. It's also guaranteed that the face is always an outer face of the wall.
Example
For a complete usage of SelectWallFace, see the example WallFaceSelection located in:
- …\etc\Examples\PythonParts\ModelObjectExamples\SelectionExamples\WallFaceSelection.pyp
- …\etc\PythonPartsExampleScripts\ModelObjectExamples\SelectionExamples\WallFaceSelection.py
Setting up a filter
The implementation of the filter can look like this:
class Object3DFilter():
""" implementation of the 3D object filter """
def __call__(self, element: AllplanEleAdapter.BaseElementAdapter):
""" execute the filtering
Args:
element: element to filter
Returns:
element fulfills the filter: True/False
"""
return element.Is3DElement()
sel_query = AllplanIFW.SelectionQuery([Object3DFilter()])
sel_setting = AllplanIFW.ElementSelectFilterSetting(sel_query, True)
The filter class is a callable Python class (a class with a __call__
member function)
that is called by Allplan for filtering.
When filtering by object type, the type of the object can be used for filter creation. The creation of the filter can be done as follows:
type_query = AllplanIFW.QueryTypeID(AllplanIFW.WallTier_TypeUUID)
sel_query = AllplanIFW.SelectionQuery(type_query)
sel_setting = AllplanIFW.ElementSelectFilterSetting(sel_query, True)
A Python list with the UUIDs is also possible as parameter for the type ID query.
After the selection interactor has been started, all mouse messages are processed by this interactor. The inputs in the property palette are managed as before in the PythonPart interactor. If the selection is to be canceled e.g., by a button click in the property palette, this can be done by calling the following function:
In the above code the running interactor is checked by the presence of the
member post_element_selection
.
After the selection is complete, the mouse messages are processed again by the PythonPart interactor. This can be used as follows to get the selected elements:
if post_element_selection:
objects = post_element_selection.GetSelectedElements(coord_input.GetInputViewDocument())
post_element_selection = None
See the API reference for the complete documentation of the classes:
- PostElementSelection
- InputFunctionStarter
- SelectionQuery
- ElementSelectFilterSetting
- InputFunctionStarter
Example
The usage of the selection classes is implemented in the example SelectObjectsWith3DGeometry located in: - …\etc\Examples\PythonParts\ModelObjectExamples\SelectionExamples\SelectObjectsWith3DGeometry.pyp - …\etc\PythonPartsExampleScripts\ModelObjectExamples\SelectionExamples\SelectObjectsWith3DGeometry.py