You are currently reviewing an older revision of this page.
During the revision of drawings, it is often necessary to adapt the alignment of all texts. This is a typical task for a VBA routine.
However, when changing the text orientation of the insertion of text (.Origin), it will sometimes automatically shift the text to an undesired location.
This undesired shift can be slightly offset by the change in the orientation by using a VBA routine to push the text back to its original point. You can use a RangeBox here, which is the smallest rectangle bounding the text.
Here is an example for how to carry this process out. In the example, the text elements must be selected in advance.
Ee = ActiveModelReference.GetSelectedElements
pOriginOld = Ee.Current.AsTextElement.Range.Low
Ee.Current.AsTextElement.TextStyle.Justification = msdTextJustificationCenterBottom
pOriginNew = Ee.Current.AsTextElement.Range.Low
pOffset.x = pOriginOld.x - pOriginNew.x
pOffset.y = pOriginOld.y - pOriginNew.y
pOffset.Z = pOriginOld.Z - pOriginNew.Z
In this example, all texts are aimed at the "bottom center" (msdTextJustificationCenterBottom)
The following (from VBA Help) is a list of all valid values for the orientation: