• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

replace existing layers with new layers

  • Thread starter Thread starter sircame
  • Start date Start date

sircame

Guest
Hi, everybody, I've been trying to figure it out myself, but in vain... then. .
I have many ctr downloaded from the various sites of the regions, and are full of layers with names on their own.
I identified the layers and divided them by category (e.g. 2e5 is a street, 1b2 is a building).
I would like to clean it with a script.

I have to select all the layers I have identified previously and put them in my new layer, practically the objects in layers 2e5, 2l12, 3a1 are put in the _strade layer, the objects of layers 1b2, 8j10 are put in the _edifici layer etc...

I can create files, I can select all the objects of that layer, what I can't do and put them in the new layer.
Any idea?
Thank you!
 
(command "_-layer" "_m" _strade" "_m" "_building" "" ) crei and layer

(setq sel (ssget "x" ((8 . "_2e5,_2l12_,3a1")))))) ottieni le entità dei layer
(command "_change" sel ""_pr" "_la" "_strade"") cambi il layer alle

(setq sel (ssget "x"(8 . "_1b2,_8j10"))))))
(command "_change" sel ""_pr" "_la" "_building"")

Bye
 
I can create files, I can select all the objects of that layer, what I can't do and put them in the new layer.
Any idea?
I modified a program (cl = change layer) that selects the elements of a layer and can copy them - move them - delete them - and now I added change layer
works like this:
1) launch the program with (load "cl")
2) click on a layer element to select (to take the layer name)
3) indicate a selection window (also partial): only the elements of that layer will be selected
4) indicate what you want to do (c-copy m-muovi e-elimia l-layercambia). in our case
5) indicate the new layer
allego is listed both the cl.lsp file
Hi.

;selectionlayer.lsp - autocad 2014
;select all entities of a layer

(if opz nil (setq opz "l"))
(setq opz1 ")
a (strcat "\nselect layer: c-copy m-muove e-elimina l-layercambia <" opz "> :")
opz1 (getstring a)
)
(if (/= opz1") (setq opz (strcase opz1))

(setq ss1 (entsel "\nsel select layer via an object")
en (car ss1) ;prelevated name (the list ss1 also contains selection point)
and (entget en) ;private data
et (cdr (assoc 8 ed) ;takes the layer
)
(prompt "\nselect the area to be selected")
(setq ss2 (ssget (cons 8 et)))))

(if (= opz "c") (command "copy" ss2"))
(if (= opz "m") (command "seat" ss2"))
(if (= opz "e") (command "cancella" ss2"))
(if (= opz "l") (command "caprop" ss2 "l"))
 

Attachments

Hello, thank you for the answers, taking cue from both lisp I was able to create one ad hoc for me. Great, it makes me the layers and then fix them as I want.
Now the last phase. the design now turns out "sporty" because it has layers old, new, lit, turned off.. etc...the final result should only be composed by my layers.
I thought, to have a result as clean as possible, to block the layers, (maybe at the stage when I create them), to display all layers of the design and delete everything. This saves only my new layers and then purge the design.
Now I try to see if I can alone... otherwise I return here... he he he he, while thank you!!! !
 
Riciao. I finished the script, at the end I simplified it and 'come out this, incool it that maybe someone can serve if he has ctr to clean.
only one thing doesn't work, since some ctr don't have retini in buildings I wanted to put a if condition with tblsearch, unfortunately it doesn't work. the 17a1 layer exists, but the function 'as if it skips this step. If I remove the tblsearch works.
Do you have any idea why?

Then... do you think you can refine this script? (only my curiosity)

Thank you

;creo all layers and lock them
(command "_-layer" "_m" "_main streets" "c" "2" "_lo" "_main streets"")
(command "_-layer" "_m" "_strade secondarie" "c" "5" "_lo" "_strade secondarie" "")
(command "_-layer" "_m" "_manufactured" "c" "1" "_lo" "_manufactured" "")
(command "_-layer" "_m" "_terrene" "c" "46" "_lo" "_terrene"")
(command "_-layer" "_m" "_water" "c" "140" "_lo" "_water"")
(command "_-layer" "_m" "_texts" "c" "2" "_lo" "_texts"")
(command "_-layer" "_m" "_simboli" "c" "1" "_lo" "_simboli"")
(command "_-layer" "_m" "_retini" "c" "5" "_lo" "_retini"")
(command "_-layer" "_set" "0"")

;transfer of old layers on new
(setq sel (ssget "x"((8 . "2e5,2h8")))))
(command "_change" sel "_pr" "_la" "_main streets"")

(setq sel (ssget "x"(8 . "2l12,3a1,2j10,2f6,2k11"))))
(command "_change" sel "_pr" "_la" "_strade secondarie"")

(setq sel (ssget "x"(8 . "1b2,8j10,1d4,1a1,1i9,2m13,1and5,1ab28,1g7,5l12")))))
(command "_change" sel "_pr" "_la" "_fabbricati"")

(setq sel (ssget "x"(8 ."5a1,3b2.5c3,6h8,22h8a,4e5.5j10,5i9,21i9")))))
(command "_change" sel "_pr" "_la" "_terrene"")

(setq sel (ssget "x"((8 . "4b2,4d4,4a1")))))
(command "_change" sel "_pr" "_la" "_acqua"")

(setq sel (ssget "x"(8 ."14g7,14p16,14o15,14r18,14f6,14d4"))))
(command "_change" sel "_pr" "_la" "_texts"")

(setq sel (ssget "x"(8 . "17e5,1l12,1k11")))))
(command "_change" sel "_pr" "_la" "_simboli"")

(if (tblsearch "layer" 17a1")
(setq sel (ssget "x"(8 . "17a1,17b2,17g7,17ab28,17e5b,17i9"))))
(command "_change" sel "_pr" "_la" "_retini"")
)

;select all design and eliminate selection
(setq sel (ssget "x"))
(command "_erase" "p"")

; purge drawing
(command "-purge" "_all" "*" "n")

; Unlock the previously blocked layers
(command "-layer" "_unlock" "*"")
 
(if (tblsearch "layer" 17a1")
(progn)
(setq sel (ssget "x"(8 . "17a1,17b2,17g7,17ab28,17e5b,17i9"))))
(command "_change" sel "_pr" "_la" "_retini"")
)
)

;select all design and eliminate selection
(setq sel (ssget "x"))
(command "_erase") "p" (command "_erase" sel ")
 
Here we go!
for me the script works well and I am happy, thank you 1000!! !
That's it.
 

Attachments

Hi, I'm still sorry, I'm pressing that the script works perfectly, so my colleagues keep offering me coffee in the morning. He he...
However, for my personal advantage, I would like to create a graphical interface to this script, a sort of gui where, once opened, I can select which layers include in the script and the color to be assigned to each layer.
I've seen a bit on the net, but I don't understand much, do you have any indications or links that are good enough to be inspired?
Thank you! ! ! !
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top