CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

活动线类型属性 (ActiveX)

2023-1-4 00:05| 发布者: admin| 查看: 396| 评论: 0|来自: AutoCAD

摘要: 指定图形的活动线型。

指定图形的活动线型。

支持的平台:仅窗口

签名

工 务 局:

object.ActiveLinetype
对象

类型:文档

此属性适用的对象。

属性值

只读:

类型:线型

图形的活动线型。

言论

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

例子

工 务 局:

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

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

GMT+8, 2024-5-19 14:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部