By Miles Nicholson
A client wanted the ability to change the linetype properties of selected blocks in a schematic to represent that this device or devices are external.
AutoCAD Electrical defaults to the SYMS layer for symbols and a linetype of CONTINUOUS.
In notepad, copy the text below and save the file as LTCHANGE.LSP in one of your support directories e.g. C:\Program Files\Autodesk\AutoCAD 2025\Support.
(defun c:LtChange (/ lt fnd s i sn name blocks)
(vl-load-com)
(if (not acdoc)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
(if (and (not (eq (setq lt (getstring "\n Specify lineType :")) ""))
(setq fnd (tblsearch "LTYPE" lt))
(setq s (ssget "_:L"))
)
(repeat (setq i (sslength s))
(setq sn (ssname s (setq i (1- i))))
(if (not (eq (cdr (assoc 0 (entget sn))) "INSERT"))
(vla-put-linetype (vlax-ename->vla-object sn) lt)
(if
(not (member (setq name (cdr (assoc 2 (entget sn)))) blocks)
)
(progn
(setq blocks (cons name blocks))
(vlax-for each (vla-item (vla-get-blocks acdoc) name)
(vla-put-linetype each lt)
)
)
)
)
)
(cond ((not lt) (princ "\n LineType is nil "))
((not fnd)
(princ "\n Couldn't find the Linetype or not loaded ")
)
(t (princ "\n Nothing has been Selected"))
)
)
(vla-regen acdoc AcallViewports)
(princ)
)
Original source: www.autolisp.com
Type APPLOAD at the AutoCAD command line and add the LSP to the Start-Up > Contents
To initialise the command type LTCHANGE
Type the name of the layer you want e.g. HIDDEN2 (must be a loaded layer in LINETYPES and within the current drawing)
Pick the blocks you wish to change.

Commentaires (0 commentaire)