ActiveLinetype プロパティ(ActiveX)

図面のアクティブな線種を指定します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

object.ActiveLinetype
object

タイプ: Document

このプロパティが適用されるオブジェクト。

プロパティの値

読み込み専用: いいえ

タイプ: Linetype

図面に対してアクティブな線種

注意

アクティブにする線種は、既に図面内に存在していなければなりません。新しい線種を作成するには、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

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