Difference between revisions of "Lines"

From Microstation VBA Wiki
Jump to: navigation, search
Line 5: Line 5:
 
</PRE>
 
</PRE>
  
Then you use a very long command to make a line (see below for more info):
+
After you define two [[Points]], you use a very long command to make a line (see below for more info):
  
 
<PRE>
 
<PRE>
Line 15: Line 15:
 
<PRE>
 
<PRE>
 
ActiveModelReference.AddElement MyLine
 
ActiveModelReference.AddElement MyLine
</PRE>
 
 
But to create the line you need a start and end point. So you have to set up variables that can hold those points. A point consists of three pieces of data for the X, Y, and Z coordinates. So once the point is set up, you have to store X and Y values in there and set Z to 0 (I'm always doing 2D, but it seems to work better with 3D points):
 
 
<PRE>
 
Dim ptStart as Point3d
 
Dim ptEnd as Point3d
 
 
ptStart.X = 10
 
ptStart.Y = 10
 
ptStart.Z = 0
 
ptEnd.X = 10
 
ptEnd.Y = 20
 
ptEnd.Z = 0
 
 
</PRE>
 
</PRE>
  

Revision as of 14:20, 5 August 2010

You can't just draw a line. Instead you have to create a line in memory and then write it to the DGN file. So in a subroutine, first you set up a variable that will hold an element.

Dim oLine As Element

After you define two Points, you use a very long command to make a line (see below for more info):

Set oLine = CreateLineElement2(Nothing, ptStart, ptEnd)

Then you write the line to the DGN file:

ActiveModelReference.AddElement MyLine

Line Characteristics

Some settings are pretty easy, able to be set by changing values of properties in ActiveSettings (color numbers are part of Microstation; 0 is white; 1 is blue; 3 is red). When you create a line, all of the ActiveSettings will be used, so to get what you want (instead of whatever the current ActiveSetting is) you need to set all of characteristics you want:

ActiveSettings.Color = 0 
ActiveSettings.LineWeight = 3

But since there are an infinite number of levels and they are named, you can't change levels quite that easily. First you have to set up a Level variable, then you can assign a level to it by looking for the name of the level (by default, levels are named "Level 1," "Level 2," etc.)

Dim oLevel as Level
Set oLevel = ActiveDesignFile.Levels.Find("Level 2")
Set ActiveSettings.Level = oLevel