CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

ActiveTextStyle Property (ActiveX)

2023-1-3 23:55| 发布者: admin| 查看: 439| 评论: 0|来自: AutoCAD

摘要: 指定绘图的活动文本样式。

指定绘图的活动文本样式。

支持的平台:仅窗口

签名

工 务 局:

object.ActiveTextStyle
对象

类型:文档

此属性适用的对象。

属性值

只读:

类型:文本样式

图形的活动文本样式。

言论

添加到图形中的新文本将采用活动文本样式。未指定不同文本样式的现有文本将采用新的活动文本样式。

对当前活动文本样式所做的更改只有在该文本样式重置为活动文本样式后才会可见。若要重置活动文本样式,只需使用更新的文本样式对象调用此属性。

注意:必须调用该方法才能看到此更改。Regen

若要为对象指定不同的文本样式,使其不会随活动文本样式一起更改,请使用 theproperty。StyleName

例子

工 务 局:

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)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 03:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部