Python

MicroStation Tools

MicroStation State Machines

Here's an inheritance diagram for DgnTool …

Inheritance Diagram for DgnTool

Source: MicroStationAPI help document.

Other Tool Classes

DgnElementSetTool inherits from less specialised classes …

MicroStation Python offers more specialised state machines that inherit from DgnElementSetTool …

ElementGraphicsTool

The ElementGraphicsTool is a tool base class for caching a geometric representation of elements.

Extracting the geometry from elements can be expensive depending on the type. Large meshes, bspline surfaces, and especially BReps are not geometry types that a tool should be extracting on every cursor motion, ex. post locate filter, but it is often necessary to query the geometry in order to properly filter on what the tool can support.

This tool base class provides a tool-scope caching strategy for the geometry of persistent elements. The cache is created on demand and cleared when the tool exits. The element's geometry by default is cached in it's natural/preferred form, but a sub-class can choose to override the collected geometry type to always cache as meshes, BReps, etc. depending on it's particular needs.

Geometry is collected in the local coordinates of the top-level/non-complex element. When collecting geometry from complex components, i.e. normal cells and shared cells, the geometry is cached on the top-level/non-complex element along with a display path that can be used to identify the specific component the geometry originated from.

This approach simplifies writing tools as iterating over potentially nested cell components or having to account for pushed transforms, such as with shared cells, becomes un-necessary.

The above information is copied from the C++ MicroStationAPI help documentation.

LocateSubEntityTool

The LocateSubEntityTool is a tool base class for picking sub-entities on element geometry (faces/edges/vertices).

Provides a way to identity and display faces, edges, and vertices of curves, surfaces, and solids. Can be used to write solid modeling tools for operations like edge blending and face offseting.

BRep geometry is not required for face, edge, and vertex selection, and collected geometry is not automatically converted to a BRep. Be aware of this when writing a solid modeling tool and override the various _OnProcess methods accordingly.

Only a ISubEntity from a ISolidKernelEntity is valid input to the solid modeling APIs. A non-BRep ISubEntity is only valid in the scope of the tool instance. Suppport for non-BRep ISubEntities is limited to simply queries, such as getting its geometry by calling GetSubEntityGeometry, as these geometry types lack connectivity information.

To force the collection of a ISolidPrimitive as a ISolidKernelEntity you would override the _OnProcessSolidPrimitive as follows:

virtual BentleyStatus _OnProcessSolidPrimitive (ISolidPrimitivePtr& geomPtr, DisplayPathCR path) override {return ERROR;}

The above information is copied from the C++ MicroStationAPI help documentation.

LA Solutions Examples

You'll find Python examples written by LA Solutions on these pages, starting here.

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.