Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify lisp to ignore locked layers.

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
675 Views, 3 Replies

Modify lisp to ignore locked layers.

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

 

3 REPLIES 3
Message 2 of 4
Shneuph
in reply to: Anonymous


@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.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 4
Anonymous
in reply to: Shneuph

Thanks Shneuph! As usual, it's always something simple. Do you know of any good references on where I could learn coding in lisp?

Message 4 of 4
Shneuph
in reply to: Anonymous

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.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost