Python

AssociativePoint & AssocPoint for Python Programmers

This article introduces class AssociativePoint and AssocPoint to MicroStation Python programmers. Associative points are used in MicroStation when one DGN graphic object is connected in some way with another DGN object. For example …

AssociativePoint

AssociativePoint is a 21st century object-oriented representation used to work with an AssocPoint. It provides initialization operations for an AssocPoint and supports resolving or maintaining the corresponding geometric location. It doesn't ancapsulate an AssocPoint.

AssociativePoint provides only static class methods. You can't construct an AssociativePoint — in other words, you can't do this …

assoc_point = AssociativePoint() # Not possible

Use one of the static methods of AssociativePoint to initialize an AssocPoint object. Once initialized, pass that object to other methods of AssociativePoint or other APIs that work with AssocPoints.

Static Methods of AssociativePoint that Initialize an AssocPoint
MethodComment
InitOrigin An association that represents the origin of an element
InitKeypoint An association that represents a point on a linear element
InitArc An association that represents a point on an arc or ellipse element
InitProjection An association that represents a point on a linear element
InitBCurve An association that represents a point on a bspline curve
InitBSurface An association that represents a point on a bspline surface
InitMeshEdge An association that represents a point on a mesh edge
InitMeshVertex An association that represents a mesh vertex
InitIntersection An association that represents the intersection of 2 curve paths

Many methods provided by AssociativePoint are wrappers around C++ functions in the MicroStationAPI that fall under the title Element Associations (mdlAssoc_xxx()).

Static Methods of AssociativePoint that set the Root of an AssocPoint
MethodComment
SetRoot Complete setup of a new associative point by setting the target/root element for the dependency by a pair of element IDs
SetRoot Complete setup of a new associative point by setting the target/root element for the dependency from a DisplayPath

AssocPoint

AssocPoint is 20th century technology. It describes how a point is attached to another element or feature — for example, to a vertex, segment location, keypoint, or other identifiable position. Its purpose is to preserve enough reference information to resolve the point again if the associated geometry changes.

The AssocPoint is a Python wrapper around the C++ struct of the same name …

struct AssocPoint
{
UShort buf[20];
};

In other words, a block of untyped data. That's not a very object-oriented way of doing things, but here we're anchored in the 20th century.

The data contained in an AssocPoint depends on how it is initialized and how the association is subsequently developed. It's possible that no two AssocPoints contain the same data.

These APIs originate in the 32-bit MicroStation era, when associative behavior was implemented through MicroStation C-style data structures and APIs. They remain relevant mainly for compatibility with existing associative data and older workflows. Their terminology and design therefore reflect older MicroStation internals rather than newer parametric-constraint or feature-modeling APIs. In practice, use them when you need to inspect, preserve, or resolve legacy associative references. Do not assume that an AssocPoint is merely an XYZ coordinate: its key value is the reference to the source geometry and the rule used to derive the point.

The AssocPoint is sufficiently small to be part of a DGN element. As you can see, an AssocPoint is not a class, contains no functionality, and relies on an external agent such as AssociativePoint to implement any functionality.

An AssocPoint is data whose purpose is to help connect one DGN object to another. It is sometimes a data source for MicroStation's dependency engine. An element that supports associative points has a dependency callback that is responsible for updating the element when the root elements change.

One may glean some ideas of its use from the API documentation. For example, the DimensionHandler class has methods InsertPoint and SetPoint that deal with AssocPoints. TextHandlerBase.SetupOffsetAssociation() accepts an AssocPoint (although that's not currently documented).

Initialization

Leonard Jones, a senior member of the Bentley Developer Network, contributed this …

AssociativePoint acts primarily as a utility class that initializes and manipulates an AssocPoint structure. Call one of the AssociativePoint.InitXXX(...) methods to initialize the association type.

For example …

assocPt1 = AssocPoint ()
assocPt2 = AssocPoint ()
AssociativePoint.InitKeypoint (assocPt1, 0, 2, 0, 1)
AssociativePoint.SetRoot (assocPt1, line_eeh.GetElementId(), 0)
AssociativePoint.InitKeypoint (assocPt2, 1, 2, 0, 1)
AssociativePoint.SetRoot (assocPt2, line_eeh.GetElementId(), 0)

Examples

There are few examples of AssociativePoint or AssocPoint in either C++ or Python in the examples delivered with MicroStation or the SDK.

I have written several Python examples that annotate a line, shape and solid. Those examples use an associative label, meaning that if you move the measured DGN element, the label follows it. See EC Examples for more detail.

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.