図面のアクティブな文字スタイルを指定します。
サポートされているプラットフォーム: Windows のみ
図面に新しい文字を追加すると、アクティブな文字スタイルが適用されます。文字スタイルを指定していない既存の文字には、新しい文字スタイルが適用されます。
現在のアクティブな文字スタイルへの変更は、その文字スタイルがアクティブな文字スタイルとしてリセットされた後にのみ反映されます。アクティブな文字スタイルをリセットするには、更新された文字スタイル オブジェクトを使ってこのプロパティを呼び出すだけです。
アクティブな文字スタイルを変更しても、オブジェクトごとの文字スタイルが変わらないようにするには、StyleName プロパティを使用します。
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)))
)