Learning MicroStation VBA

Chapter 15: Adding To Documents

We have created lines, circles, arcs, and text as we introduced programming topics. Let's examine the specifics of adding elements and other objects to our design files. We begin with graphical elements and then work on non-graphical elements such as levels.

Graphical Elements

There are two steps to adding elements to our design files. First we create the element in memory. Then we add the element to our design file. As you will see, there is often more than one way to create the element. We will demonstrate multiple examples of each creation method.

Lines

"The shortest distance between two points is a straight line." If this is true, we should be able to create a line by providing two points, right?

Well, that is one way to create a line. We can also provide an array of vertices if we want to draw more than one line.

  • Function CreateLineElement1(Template As Element, Vertices() As Point3d) As LineElement

  • Function CreateLineElement2(Template As Element, StartPoint As Point3d, EndPoint As Point3d) As LineElement

Sub <b class="bold">TestCreateLineA</b>()    Dim StPt As Point3d    Dim EnPt As Point3d    Dim myLine As LineElement    EnPt.X = 4: EnPt.Y = 6: EnPt.Z = 8    Set myLine = CreateLineElement2(Nothing, StPt, EnPt)    ActiveModelReference.AddElement myLineEnd Sub<a name="578"></a><a name="beginpage.8F7FC088-42BE-4419-8EDA-ECD6783017CC"></a>

TestCreateLineA uses the CreateLineElement2 method to create a new line element. It does so using a start point and an end point.

Sub <b...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Vacuum Valves
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.