Difference between revisions of "Text"

From Microstation VBA Wiki
Jump to: navigation, search
Line 1: Line 1:
 
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.
 
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:
+
First you have to set up a variable to hold the text element, [[Rotation Matrix]] and text string:
  
 
<PRE>
 
<PRE>
Line 15: Line 15:
 
ActiveSettings.TextStyle.Height = 2 * sca
 
ActiveSettings.TextStyle.Height = 2 * sca
 
ActiveSettings.TextStyle.Width = 2 * sca
 
ActiveSettings.TextStyle.Width = 2 * sca
 +
oMatrix=Matrix3dIdentity
 
</PRE>
 
</PRE>
  
Line 20: Line 21:
  
 
<PRE>
 
<PRE>
Set oText = CreateTextElement1(Nothing, strText, ptStart, Matrix3dIdentity)
+
Set oText = CreateTextElement1(Nothing, strText, ptStart, oMatrix)
 
ActiveModelReference.AddElement oText
 
ActiveModelReference.AddElement oText
 
</PRE>
 
</PRE>
 +
 +
If you aren't rotating the text, you don't have to set up a matrix element and can just put Matrix3dIdentity in the function call.

Revision as of 14:09, 5 August 2010

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, Rotation 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
oMatrix=Matrix3dIdentity

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

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

If you aren't rotating the text, you don't have to set up a matrix element and can just put Matrix3dIdentity in the function call.