Hello Everyone,
I have a lisp that I would like to use but I do not want it to affect locked layers. Could someone point me in the right direction on how to modify this lisp? I'm starting to get familiar with lisp programming but this code looks different than what I have been using. This lisp simply takes all text and puts it on a new layer called "Layer"-Text. I have one layer of text that I do not want to change. I'm hoping to just keep the layer locked while the lisp runs.
As always, any help is greatly appreciated.
(defun c:ToText (/ la name lk ss new) ;; Move all *Text and *Leaders to a text layer, matching primary layer (eg. ALAN -> ALAN-TEXT) ;; Includes objects on locked layers ;; Layer created if doesn't exist (also takes on color of primary layer) ;; Alan J. Thompson, 08.19.10 (vl-load-com) (vlax-for l (setq la (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) ) (or (wcmatch (strcase (setq name (vla-get-name l))) "*-TEXT,*$*") (if (setq ss (ssget "_X" (list '(0 . "*LEADER,*TEXT") (cons 8 name)))) (progn (and (setq lk (eq :vlax-true (vla-get-lock l))) (vla-put-lock l :vlax-false)) (or (tblsearch "LAYER" (setq new (strcat name "-TEXT"))) (vla-put-color (vla-add la new) (vla-get-color l)) ) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (vl-catch-all-apply (function vla-put-layer) (list x new)) ) (vla-delete ss) (and lk (vla-put-lock l :vlax-true)) ) ) ) ) (princ) )
@Anonymous wrote:I have one layer of text that I do not want to change. I'm hoping to just keep the layer locked while the lisp runs.
Maybe here:
(or (wcmatch (strcase (setq name (vla-get-name l))) "*-TEXT,*$*")
You can add an exclusion to the wcmatch string like
"*-TEXT,*$*,~LayerNameToIgnore"
I haven't tried it.
Thanks Shneuph! As usual, it's always something simple. Do you know of any good references on where I could learn coding in lisp?
If you do a search in this discussion group there are many posts about LISP references. Afralisp.net is populare as well as the Autocad developers help menu.