Remapping Layer Names, Colours and Linestyles

Remapping Layer Names, Colours and Linestyles

mhan0017
Explorer Explorer
1,714 Views
9 Replies
Message 1 of 10

Remapping Layer Names, Colours and Linestyles

mhan0017
Explorer
Explorer

I have been looking around for a lisp routine to automatically change a set of layer names to a different name as well as set a layer colour and linestyle. 

 

I have very little knowledge of lisps and can only manage to make minor changes to existing routines

 

I have attempted to do this using a script however because my outputs for each new file will contain a different set of layers (a select few from a possible list of 500 layer names) each time the script often stops.

 

I have a table of possible output layer names, new layer names, colour and linestyle. I also want to merge an output layer into its new layer if it already exists.

0 Likes
1,715 Views
9 Replies
Replies (9)
Message 2 of 10

Moshe-A
Mentor
Mentor

@mhan0017 hi,

 

before going to lisp explore CHECKSTANDARDS command.

 

moshe

 

0 Likes
Message 3 of 10

mhan0017
Explorer
Explorer

thanks Moshe,

 

This appears to do what i am after.

 

Is it possible to automate the standard changes as they will be the same for each drawing i create? or will i have to manually select each fix for every non-standard each time?

 

Ideally i would like to run "checkstandards" and all of my layers etc. to change without manually choosing a fix every time

0 Likes
Message 4 of 10

Moshe-A
Mentor
Mentor

make a list of all your new layers name + color + ltype and existing layer to be replace in this format

 

new_layer               color      ltype                existing_layer_to be_replaced

CONC_WALLS             4         Continuous        WALLS

SOUTH_VIEW             2         Continuous        VIEWS

DIMENSIONS             7         Continuous        DIMS

ANNOTATIONS           7         Continuous       TEXT

GRID_LINES               1          DASHDOT          CL

HIDDEN_LINES         3         HIDDEN              OBSCURE 

 

moshe

 

0 Likes
Message 5 of 10

mhan0017
Explorer
Explorer

i have created a text file in this format but am not sure how to make the check standards tool read this information to remap the layers. it only allows me to attach a dws file using the tool

0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant

@mhan0017 wrote:

.... they will be the same for each drawing i create? ....


 

For that, set them up as you want them in your default drawing template file, and they will be the same for each new drawing [unless you select a template file different from the default for a given drawing].

Kent Cooper, AIA
0 Likes
Message 7 of 10

Moshe-A
Mentor
Mentor

post the text file here, the solution will be with lisp

0 Likes
Message 8 of 10

Moshe-A
Mentor
Mentor

@mhan0017, hi

 

here is the lisp. the main database is a list (layer_data^) built by sublists which are layer records.

each record is a list of 4 items\fields where the first is old layer name, the second is the new layer name, third is the color and the last is ltype.

 

your part in this 'project' is to populate layer_data^ with yours layers (you can delete my example records).

 

if record first field is "$create" (must stay lowercase) then the layer is added as new.   

 

enjoy

moshe

 

 

 

; Rename Layers
(defun c:RL1  (/ layer_data^ old_layer new_layer ent elist)
 (setvar "cmdecho" 0)
 (command "._undo" "_begin")
  
 (setq layer_data^ '(("WALLS"   "CONC_WALLS"   4 "Continuous")
		     ("VIEWS"   "SOUTH_VIEW"   2 "Continuous")
		     ("DIMS"    "DIMENSIONS"   7 "Continuous") 
                     ("TEXT"    "ANNOTATION"   7 "Continuous")
		     ("CL"      "GRID_LINES"   1 "dashdot")
		     ("OBSCURE" "HIDDEN_LINES" 3 "hidden")
		     ("$create" "BLOCK_WALLS"  6 "Continuous")
		    )
 )

 (foreach item layer_data^
  (setq old_layer (car item))
  (setq new_layer (cadr item))
   
  (cond
   ((eq old_layer "$create")
    (cond
     ((tblsearch "layer" new_layer) ; layer already exist?
      (cond
       ((= (logand (cdr (assoc '70 elist)) 16) 16) ; is xref depended?
        (prompt (strcat "\nLayer \"" (strcase new_layer) "\" is xref depended."))
       );case
       ((= (logand (cdr (assoc '70 elist)) 4) 4) ; is layer lock?
        (prompt (strcat "\nLayer \"" (strcase new_layer) "\" is locked."))
       ); case
       ( t
        (command "._layer" "_color" (caddr item) new_layer "_ltype" (cadddr item) new_layer "")
       ); case
      ); cond
     ); case
     ((not (snvalid new_layer))
      (prompt (strcat "\ncan not create layer by that name \"" (strcase new_layer) "."))
     ); case
     ( t
      (command "._layer" "_new" new_layer "_color" (caddr item) new_layer "_ltype" (cadddr item) new_layer "") 
     ); case
    ); cond
   ); case
   ( t
    (if (and
	 (setq ent (tblobjname "layer" old_layer))
	 (setq elist (entget ent))
        )
     (cond
      ((= (logand (cdr (assoc '70 elist)) 16) 16) ; is xref depended?
       (prompt (strcat "\nLayer \"" (strcase old_layer) "\" is xref depended."))
      );case
      ((= (logand (cdr (assoc '70 elist)) 4) 4) ; is layer lock?
       (prompt (strcat "\nLayer \"" (strcase old_layer) "\" is locked."))
      ); case
      ((not (snvalid new_layer))
       (prompt (strcat "\ncan not create layer by that name \"" (strcase new_layer) "."))
      ); case
      ( t
       (command "._rename" "_layer" old_layer new_layer)
       (command "._layer"  "_color" (caddr item) new_layer "_ltype" (cadddr item) new_layer "") 
      ); case
     ); cond
    ); if
   ); case
  ); if
 ); foreach

 (command "._undo" "_end")
 (setvar "cmdecho" 1)
  
 (princ)
); C:RL1

 

 

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hey, I'm not sure if this is the correct location to post this but I'm in need of some help. I'm trying to create a lisp that uses wildcards to select key words and automatically put them on a predefined layer. I have something like this so far.

 

(defun c:LAYCH ( / n )
  (setvar 'CLAYER "0")
  (while (setq d (tblnext "LAYER" (null d)))
    (if (and (not (wcmatch (setq n (strcase (cdr (assoc 2 d)))) "*|*,0,DEFPOINTS, D-DETL-TEXT"))
             (wcmatch n "*text*,*dim*")
     )
   (vl-catch-all-apply 'vla-put-name (list layer "C-DETL-TEXT")
   )
   )
 )
 (princ)
)
 
Basically, I want to put all text on C-DETL-TEXT but not include the actual layer to be put on in the search. I also want to add other "if statements" to include other key words to put like, "wall, building, etc." on the layer "C-DETL-LINE."
 
Can anyone else? It seems like what I have isn't working correctly. Thanks
0 Likes
Message 10 of 10

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

you are right, this is not the place to put a new thread, you need to start a new of yours.

 

0 Likes