CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2019 开发者帮助

ActiveLinetype 属性 (ActiveX)

2024-5-18 17:52| 发布者: admin| 查看: 75| 评论: 0|原作者: admin|来自: AutoCAD

ActiveLinetype 属性 (ActiveX)

指定绘图的活动线型。

支持的平台:仅限 Windows

签名

VBA:

object.ActiveLinetype
对象

类别: 文档

此属性应用于的对象。

属性值

只读:

类型:线型

绘图的活动线型。

言论

图形中必须已存在指定的线型。若要添加新的线型,请使用该方法。Add

例子

VBA:

Sub Example_ActiveLinetype()
    ' This example finds the current linetype. It then sets
    ' the new linetype to be the first entry in the linetype
    ' collection that is not equal to the current linetype.
    ' Finally, it resets the active linetype to the original
    ' setting.
    
    Dim currLineType As AcadLineType
    Dim newLineType As AcadLineType
    
    ' Find the current LineType of the active document
    Set currLineType = ThisDrawing.ActiveLinetype
    MsgBox "The current linetype is " & currLineType.name, vbInformation, "ActiveLinetype Example"
    
    ' Set the current Linetype to anything else in the collection
    Dim entry
    Dim found As Boolean
    For Each entry In ThisDrawing.Linetypes
        If StrComp(entry.name, currLineType.name, 1) <> 0 Then
            Set newLineType = entry
            found = True
            Exit For
        End If
    Next
    If found Then
        ThisDrawing.ActiveLinetype = newLineType
        MsgBox "The new linetype is " & newLineType.name, vbInformation, "ActiveLinetype Example"
        ' Reset the linetype to the previous setting
        ThisDrawing.ActiveLinetype = currLineType
        MsgBox "The active linetype is reset to " & currLineType.name, vbInformation, "ActiveLinetype Example"
    End If
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_ActiveLinetype()
    ;; This example finds the current linetype. It then sets
    ;; the new linetype to be the first entry in the linetype
    ;; collection that is not equal to the current linetype.
    ;; Finally, it resets the active linetype to the original
    ;; setting.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Find the current LineType of the active document
    (setq currLineType (vla-get-ActiveLinetype doc))
    (alert (strcat "The current linetype is " (vla-get-Name currLineType)))
    
    ;; Set the current Linetype to anything else in the collection
    (setq newLineType nil)
    (setq found :vlax-false)
    (vlax-for each-linetype (vla-get-Linetypes doc)
        (if (and (/= (vla-get-Name each-linetype) (vla-get-Name currLineType)) (/= found :vlax-true))
            (progn
                (setq newLineType each-linetype)
                (setq found :vlax-true)
            )
        )
    )
  
    (if (= found :vlax-true)
        (progn
            (vla-put-ActiveLinetype doc newLineType)
            (alert (strcat "The new linetype is " (vla-get-Name newLineType)))
            ;; Restore the previous linetype
            (vla-put-ActiveLinetype doc currLineType)
            (alert (strcat "The active linetype is restored to " (vla-get-Name currLineType)))
        )
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:02

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部