The Element Picker tool is a very simple tool that inherits from the MicroStation Python DgnElementSetTool.
class ElementPicker(DgnElementSetTool):
def __init__(self, toolId: int):
"""
Initialize the ElementPicker.
param toolId: The ID of the tool.
"""
DgnElementSetTool.__init__(self, toolId: int) # C++ base's __init__ must be called.
self.m_isDynamics = False
self.m_ev = None
self.m_self = self # Keep self-referenced. This variable is used by the base class DgnElementSetTool.
The purpose of Element Picker is trivial: when you pick an element it reveals information about that element in its
_OnElementModify event …
def _OnElementModify(self, eeh: EditElementHandle)->BentleyStatus:
"""
Modify the given element if required. For this element picker,
we simply dump information about the element but make no change.
:param eeh: The element you picked.
:returns: The status of the modification.
"""
description = get_element_description(eeh)
print(f"{description} ID={eeh.GetElementId()}")
MessageCenter.ShowInfoMessage(description, description, False)
You'll find Python examples written by LA Solutions on these pages, starting here.
Visit the LA Solutions' State Machine examples Download page.
Post questions about MicroStation programming to the MicroStation Programming Forum.