Questions similar to this appear on the Bentley Discussion Groups. This problem appeared in the VBA discussion group.
Q How do I create a shape element using VBA?
A
Create a class module that implements IPrimitiveCommandEvents. Use a member variable
to store an elastic array of Point3d, and another member variable to track how many points the user has supplied.
With those pieces of data, you have enough information to display rubber banding as the user places datapoints.
The example CreateShape class Implements IPrimitiveCommandEvents by providing
a number of methods that MicroStation calls when certain events happen. Events that are interesting in this example are …
Initialise our variables and issue a prompt to the user.
Store the Point3d in our array of vertices, and increment the vertex count.
Create a temporary shape from our array of vertices and the current cursor position. Each time the user moves the mouse, MicroStation calls this subroutine to draw a new shape.
Create a shape from our array of vertices and add it to the model.
The CreateShape VBA Project is available in this ZIP file.
Unpack the ZIP file and put CreateShape.mvba somewhere where MicroStation can find it, such as
C:\Program Files\Bentley\Workspace\Standards\vba.
You can run the sample using the keyin …
vba run [CreateShape]CreateShapeMain.Main