Specifies the active text style for the drawing.
Supported platforms: Windows only
New text added to the drawing will adopt the active text style. Existing text that has no distinct text style specified will adopt the new active text style.
Changes made to the current active text style will become visible only after that text style is reset as the active text style. To reset the active text style, simply call this property with the updated text style object.
To specify a distinct text style for an object so it will not change along with the active text style, use the StyleName property.
VBA:
Sub Example_ActiveTextStyle() ' This example returns the current text style ' and then sets a new style. ' Finally, it returns the style to the previous setting. Dim newTextStyle As AcadTextStyle Dim currTextStyle As AcadTextStyle ' Return current text style of active document Set currTextStyle = ThisDrawing.ActiveTextStyle MsgBox "The current text style is " & currTextStyle.name, vbInformation, "ActiveTextStyle Example" ' Create a text style and make it current Set newTextStyle = ThisDrawing.TextStyles.Add("TestTextStyle") ThisDrawing.ActiveTextStyle = newTextStyle MsgBox "The new text style is " & newTextStyle.name, vbInformation, "ActiveTextStyle Example" ' Reset the text style to its previous setting ThisDrawing.ActiveTextStyle = currTextStyle MsgBox "The text style is reset to " & currTextStyle.name, vbInformation, "ActiveTextStyle Example" End Sub
Visual LISP:
(vl-load-com) (defun c:Example_ActiveTextStyle() ;; This example returns the current text style ;; and then sets a new style. ;; Finally, it returns the style to the previous setting. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Return current text style of active document (setq currTextStyle (vla-get-ActiveTextStyle doc)) (alert (strcat "The current text style is " (vla-get-Name currTextStyle))) ;; Create a text style and make it current (setq textStyles (vla-get-TextStyles doc)) (setq newTextStyle (vla-Add textStyles "TestTextStyle")) (vla-put-ActiveTextStyle doc newTextStyle) (alert (strcat "The new text style is " (vla-get-Name newTextStyle))) ;; Restore the previous text style (vla-put-ActiveTextStyle doc currTextStyle) (alert (strcat "The text style is restored to " (vla-get-Name currTextStyle))) )