Specifies the active linetype for the drawing.
Supported platforms: Windows only
The specified linetype must already exist in the drawing. To add a new linetype, use the Add method.
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))) ) ) )