layer rename lisp

layer rename lisp

Anonymous
Not applicable
6,272 Views
22 Replies
Message 1 of 23

layer rename lisp

Anonymous
Not applicable
I'm looking for a lisp to automatically add a prefix or suffix to all
existing layer names in a drawing.

--

Jim Hill
Curtis + Ginsberg Architects LLP
www.cplusga.com
0 Likes
6,273 Views
22 Replies
Replies (22)
Message 21 of 23

Kent1Cooper
Consultant
Consultant

@sigmmadesigner wrote:

(defun c:LL ()
....


I fail to see what that has to do with Renaming Layers, but just for your information, it can be much shorter.  You can do multiple Layer operations in one  Layer command [which will also make it faster, not getting in and out of (command) functions again and again], and you can assign Layer options [such as Color] to more than one  Layer at a time with comma-separated Layer names, and you don't  have to specify Continuous as a linetype, since that is always the default.

 

(defun c:LL ()
  (command "_.layer"
    "_new" "ALVENARIA DE PROJETO,ALVENARIA DE DEMOLIÇÃO,LINHA DE CORTE,NBR,LINHA DE COTA,TRAÇO FINO,DETALHE FINO"

    "_new" "DETALHE MÉDIO,TRAÇO MEDIA,TEXTO ARIAL,TEXTO ROMANS,TEXTO TÍTULO,JARDINAGEM,AREA,FORMATO,MOBILIARIO,HIDRO"
    "_color" "250" "ALVENARIA DE PROJETO"
    "_color" "1" "ALVENARIA DE DEMOLIÇÃO,AREA"
    "_color" "3" "ALVENARIA DE REFORMA"
    "_color" "4" "LINHA DE CORTE,NBR"
    "_color" "252" "LINHA DE COTA,TRAÇO FINO,DETALHE FINO"
    "_color" "255" "DETALHE MÉDIO,MOBILIARIO,HIDRO"
    "_color" "7" "TRAÇO MEDIA,TEXTO ARIAL,TEXTO ROMANS",TEXTO TÍTULO,FORMATO"
    "_color" "79" "JARDINAGEM"
    "" ; [end Layer command]
  ); command
  (princ)
); defun
(defun c:CAMADA () (C:LL))

 

[You can put all the "_new" Layer names into one  continuous string -- I just broke it into two groups for website display.]

Kent Cooper, AIA
0 Likes
Message 22 of 23

ahsattarian3
Enthusiast
Enthusiast

This Woks :

 

 

(defun c:rl ()
(setq p (getstring t "\n Prefix of all the layers : "))
(setq s (getstring t "\n Suffix of all the layers : "))
(setq aa nil)
(setq lali nil)
(setq aa (tblsearch "layer" "0" t))
(setq lali (append lali (list (list (cdr (assoc 2 aa)) (cdr (assoc 62 aa))))))
(while
(setq aa (tblnext "layer"))
(setq lali (append lali (list (list (cdr (assoc 2 aa)) (cdr (assoc 62 aa))))))
)
(setq k -1)
(setq n (length lali))
(setvar "cmdecho" 0)
(repeat n
(setq k (1+ k))
(setq ll (nth k lali))
(setq l (car ll))
;;(setq lnew (strcat p "-" l "-" s))
(setq lnew (strcat p l s))
(if (and (/= l "0") (/= l "ashade"))
(command "rename" "layer" l lnew)
)
(princ (strcat "\n Layer : " l " ---> " lnew))
)
(princ)
)

0 Likes
Message 23 of 23

DannyNL
Advisor
Advisor

Be aware you are all responding to a thread from 2011 which was brought back to life by rrushfield.

And he already responded he posted in the wrong forum thread Smiley Happy

0 Likes