Text

From Microstation VBA Wiki
Revision as of 15:01, 5 August 2010 by Ted (talk | contribs)
Jump to: navigation, search

Placing text is much more dependent on ActiveSettings, so the command itself is pretty simple. It involves setting up a point (like lines or cells) and a rotation matrix, and giving the text to be placed, but otherwise most of the settings are stored in a property of ActiveSettings called TextStyle, which itself has a number of properties like Width, Height, and Justification.

First you have to set up a variable to hold the text element, matrix and text string:

Dim oText as TextElement
Dim oMatrix as Matrix3d
Dim strText as String

Before creating the text elements, make sure the ActiveSettings are what you want. For Justification there are a bunch of program constant names that can be used:

ActiveSettings.TextStyle.Justification = msdTextJustificationCenterBottom
ActiveSettings.TextStyle.Height = 2 * sca
ActiveSettings.TextStyle.Width = 2 * sca

Then you store the element in your TextElement variable and add it to the drawing:

Set oText = CreateTextElement1(Nothing, strText, ptStart, Matrix3dIdentity)
ActiveModelReference.AddElement oText