Please follow the MicroStation Programming forum best practices.
Identify Your Platform
Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8i. What is the 8-digit version number (e.g. 10.xx.yy.zz) of MicroStation?
The APIs supplied with MicroStation CONNECT are different to those supplied with MicroStation V8i. Consequently, our answers are likely to be different.
Code Syntax Highlighting
When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:
Dimensionality
Is your DGN model 2D or 3D? That makes a big difference to your algorithm design.
Point in Shape
First, write a command class that Implements ILocateCommandEvents. In your class _Start event method, set the LocateCriteria to reject all elements except
shape elements. There are examples in VBA help.
One solution to your question might be to set MicroStation's LocateTolerance temporarily to as large as the largest shape you want to identify. A crude but possibly useful way to go.
If you really want to implement point-inside-polygon selection, then you'll have to be imaginative because MicroStation doesn't directly support that idiom. Here is a couple of suggestions...
- Build a list of shapes in the DGN model
- Use Element.Range to eliminate shapes that can't possibly contain your point
- Examine the remaining shapes to see if Point3dInPolygonXY is true
- Use VBA's GetFloodBoundary around the current point
- Compare the boundary element created with the nearest shape