Author Topic: Converting all layers to another set of layers  (Read 2513 times)

0 Members and 1 Guest are viewing this topic.

CottageCGirl

  • Guest
Converting all layers to another set of layers
« on: July 30, 2018, 08:51:17 AM »
I couldn't find a topic match for this..

What are some efficient ways to do this.

Acad.. we run one set of layers and need to change all layers to another set for presentation purposes  on a regular basis.

Would a lisp work or is this best achieved using layer states?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Converting all layers to another set of layers
« Reply #1 on: July 30, 2018, 09:39:44 AM »
LAYTRANS ?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Converting all layers to another set of layers
« Reply #2 on: July 30, 2018, 10:02:45 AM »
Any XREF-dependent layers?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Converting all layers to another set of layers
« Reply #3 on: July 31, 2018, 04:00:24 AM »
LAYTRANS ?

Amen, this is precisely what LAYTRANs is designed to do, and IMHO it's pretty good at it.

Once you've done the first one you can save a translation as a profile to repeat it, or you can remap new layers each time (using any drawing for your target layers) or a combination of the two.  There's also a "Map same" button, so that if you've adjusted, for example, a received file and then get set an update you can use this to perform the same adjustments.

dJE
===
dJE

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: Converting all layers to another set of layers
« Reply #4 on: July 31, 2018, 10:59:18 AM »
Give this a try
Rename layers
List of old layers name
Code - Auto/Visual Lisp: [Select]
  1. ("ARSTAIR" "ARPARTITION" "ARWOOD" "ARFURNITURE""ARWINDOW" )
List of new layers name
Code - Auto/Visual Lisp: [Select]
  1. ("A-Flor-Strs" "A-Flor-Tptn" "A-Flor-Wdwk" "A-Furn" "A-Glaz")

Then Modify layers


Code - Auto/Visual Lisp: [Select]
  1. ;;example
  2. (defun c:test ( )
  3.   (mapcar '(lambda ( a b ) (renlay a b ))
  4.           '("ARSTAIR" "ARPARTITION" "ARWOOD" "ARFURNITURE""ARWINDOW" )
  5.           '("A-Flor-Strs" "A-Flor-Tptn" "A-Flor-Wdwk" "A-Furn" "A-Glaz")
  6.           )
  7.   (foreach args
  8.            '(
  9.              ("A-Flor-Strs"     1 "Continuous" 0.13 T 0         "A-Flor-Strs")
  10.              ("A-Flor-Tptn"     20 "HIDDEN" 0 T 0               "A-Flor-Tptn")
  11.              ("A-Flor-Wdwk"     3 "Continuous" 0 T 0            "A-Flor-Wdwk")
  12.              ("A-Furn"  8 "Continuous" 0 T 0            "A-Furn")
  13.              ("A-Glaz"  5 "Continuous" 0 T 0            "A-Glaz")
  14.              )
  15.     (apply 'lyrmk args))
  16.   )
  17.  
  18. ;;function to rename a layer.
  19. ;;if old layer exists, and new layer doesn't exist, the old layer is simply renamed.
  20. ;;if old layer exists, and new layer is already there, it takes everything on old layer and puts them on new layer.
  21. ;;if old layer doesn't exist, it does nothing.
  22. (defun renlay (ol nl / ss i ent )
  23.   (cond ((and (tblsearch "layer" ol) (not (tblsearch "layer" nl)))
  24.          (command "._rename" "la" ol nl)
  25.         )
  26.         ((and (tblsearch "layer" ol)(tblsearch "layer" nl))
  27.           (setq ss (ssget "x" (list (cons 8 ol))))
  28.           (setq i -1)
  29.            (repeat (sslength ss)
  30.               (setq ent (entget (ssname ss (setq i (1+ i))))
  31.                     ent (subst (cons 8 nl) (cons 8 (cdr (assoc 8 ent))) ent)
  32.               )    
  33.               (entmod ent)
  34.            )
  35.         )
  36.         ((not (tblsearch "layer" ol))
  37.           (prompt (strcat "\nLayer " ol " not found. "))
  38.         )
  39.   )
  40.   (princ)
  41. )
  42.  
  43. (defun lyrmk (Nme Col lTyp lWgt Plt trns dsc / lay lyrs cmd) ;lee mac
  44.   ;http://www.cadtutor.net/forum/showthread.php?36882-Check-create-layer-issue-in-Lisp&p=243520&viewfull=1#post243520
  45.   (setq cmd (getvar 'cmdecho))
  46.   (setvar 'cmdecho 0)  
  47.   (if (not (tblsearch "LAYER" Nme))
  48.     (progn
  49.       (setq lay (vla-add lyrs Nme))
  50.       ;(mdfy)
  51.         (setq entVL (vlax-ename->vla-object (tblobjname "LAYER" Nme)))
  52.       (and Col (vla-put-Color entVL Col))
  53.       (and lTyp (lTload lTyp) (vla-put-Linetype entVL lTyp))
  54.       ;  (and lWgt (vla-put-LineWeight entVL (eval (read (strcat "acLnWt" lWgt)))))
  55.       (and lWgt (vl-cmdf "_.-layer" "_LWeight" lWgt Nme ""))
  56.       (and (not Plt) (vla-put-Plottable entVL :vlax-false))
  57.       (and (setq LyrDs (vlax-put-property entVL 'Description dsc)))
  58.       (vl-cmdf "_.-layer" "_TR" trns Nme "")
  59.       )
  60.     (progn
  61.       (setq entVL (vlax-ename->vla-object (tblobjname "LAYER" Nme)))
  62.       (and Col (vla-put-Color entVL Col))
  63.       (and lTyp (lTload lTyp) (vla-put-Linetype entVL lTyp))
  64.       ;  (and lWgt (vla-put-LineWeight entVL (eval (read (strcat "acLnWt" lWgt)))))
  65.       (and lWgt (vl-cmdf "_.-layer" "_LWeight" lWgt Nme ""))
  66.       (and (not Plt) (vla-put-Plottable entVL :vlax-false))
  67.       (and (setq LyrDs (vlax-put-property entVL 'Description dsc)))
  68.       (vl-cmdf "_.-layer" "_TR" trns Nme "")))
  69.   (setvar 'cmdecho cmd))
  70.  
  71. (defun lTload (lTyp)
  72.   (or (tblsearch "LTYPE" lTyp)
  73.                 lTyp
  74.                 "acad.lin")))
  75.  
  76.  
  77.  
  78.