Learning MicroStation VBA

Chapter 13: The MicroStation Object Model - Types

Overview

Thus far we have introduced and discussed concepts such as variables, objects, properties, and methods. We are now going to discuss types.

A type is used like a variable but is similar to an object because it holds multiple elements. The best way to demonstrate this is by looking at a type we will use extensively in our MicroStation VBA programming.

Type Point3d     X As Double     Y As Double     Z As DoubleEnd Type<a name="559"></a><a name="beginpage.7F69F480-B2B3-4DA8-B8FF-DA9A9946BA55"></a>

The Point3d type has three members: X (which is a Double), Y (which is a Double) and Z (which is a Double).

Sub <b class="bold">TestPoint3d</b>()    Dim StartPoint As Point3d    Dim EndPoint As Point3d    Dim MyLine As LineElement    StartPoint.X = 1.5    StartPoint.Y = 2.5    StartPoint.Z = 3.5    EndPoint.X = 4    EndPoint.Y = 0    EndPoint.Z = 0    Set MyLine = CreateLineElement2(Nothing, StartPoint, EndPoint)    ActiveModelReference.AddElement MyLineEnd Sub

We declare two variables with a type of "Point3d". We assign coordinate values to the X, Y, and Z elements of these variables. They are then used with the CreateLineElement2 method. Here is the declaration for "CreateLineElement2":

Sub CreateLineElement2(Template As Element, StartPoint As Point3d, _EndPoint As Point3d) as LineElement

Notice how this method is asking for two Point3d Types one for the Start Point...

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: Depolarizers
Finish!
Privacy Policy

This is embarrasing...

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