Hsanon Posted March 9, 2015 Share Posted March 9, 2015 hi, can someone let me know of a routine which moves selected objects (on separate layers) into another layer (say layer 0 ) but the objects need to keep the same colours of the original layers (byblock) I am trying to reduce the number of layers in a drawing by pushing them all into a separate layer, but they all become bylayer taking on the new layer colour and i cannot distinguish the various elements ... thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 9, 2015 Share Posted March 9, 2015 Try this routine and change the variable 'lay' according to your target layer name . (defun c:Test (/ lay i ss sn) ;;; Tharwat 09.03.2015 ;;; (setq lay [color=red]"0"[/color]) [color=red];; <<= change the layer name as per your required one [/color] (if (and (tblsearch "LAYER" lay) (princ (strcat "\n Select objects to move to layer < " lay " > .")) (setq i -1 ss (ssget "_:L" '((0 . "~VIEWPORT")))) ) (while (setq sn (ssname ss (setq i (1+ i)))) (entmod (subst (cons 8 lay) (assoc 8 (setq e (entget sn))) e)) ) (princ "\n Failed !. Layer not found or nothing selected by the user ") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Hsanon Posted March 10, 2015 Author Share Posted March 10, 2015 thanks for your help Tharwat.... the entities can move to layer 0, but the entity colours become the colour of the layer 0 (bylayer) i was looking at the entities to come into layer 0, with different colours - (which were the colours as seen in the original layers) i.e. if the entities were red bylayer in layer 1, and green bylayer in layer 2, when they come into layer 0, they still come in as red and green.... it keeps the drawing looking interesting thanks. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 10, 2015 Share Posted March 10, 2015 It should not change the color of entities and it moves entities to layer 0 only . Quote Link to comment Share on other sites More sharing options...
Hsanon Posted March 10, 2015 Author Share Posted March 10, 2015 guwahati survey for dwg insert.dwg i am attaching a messy drawing with a bunch of layers ... all with its own bylayer colour objects. I would like the objects in these various layers be moved to layer 0, but to maintain the same old colours (byblock) which they had in their previous layers. and remove the older various layers. it will make the drawing look more interesting than all objects having one flat single colour of layer 0 thanks (have tried to insert a drawing ... hope its been attached) Quote Link to comment Share on other sites More sharing options...
Hsanon Posted March 10, 2015 Author Share Posted March 10, 2015 i.e. the red coloured objects remain red in layer 0, the green/blue /yellow etc objects come in as green/blue/yellow objects in layer 0 etc..... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 10, 2015 Share Posted March 10, 2015 If I've understood correctly, please try the following: (defun c:movetolayer ( / des enx idx lay lst sel ) (setq des "0") ;; Destination Layer (created if not present) (if (setq sel (ssget "_:L")) (repeat (setq idx (sslength sel)) (setq enx (entget (ssname sel (setq idx (1- idx)))) lay (assoc 8 enx) enx (subst (cons 8 des) lay enx) ) (if (not (assoc 62 enx)) (setq enx (append enx (list (cond ( (cdr (assoc lay lst))) ( (cdar (setq lst (cons (cons lay (cons 62 (abs (cdr (assoc 62 (tblsearch "layer" (cdr lay) ) ) ) ) ) ) lst ) ) ) ) ) ) ) ) ) (entmod enx) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 10, 2015 Share Posted March 10, 2015 I think you want to move objects to a specific layer and re-color each object according to its original color in its original layer . Your first post does not give any hint about this goal . but anyway Lee step over and gave you the one before I read your attached drawing . Quote Link to comment Share on other sites More sharing options...
Hsanon Posted March 11, 2015 Author Share Posted March 11, 2015 Sorry for not being too clear in my post... yes this was exactly what i needed... and Lee's program works !!!! thanks so much for your help.... !!!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 11, 2015 Share Posted March 11, 2015 You're most welcome Hsanon - I'm glad it works for you. Quote Link to comment Share on other sites More sharing options...
Hsanon Posted March 15, 2015 Author Share Posted March 15, 2015 Lee, fyi, the name is Harsh Sanon.... (not the "english" harsh) i am a 50 year old architect .... i started autocad and dabbled in autolisp when i was younger, half my age,, and made a bunch of drafting programs which i still use personally. however, ive lost my knack of writing now..... am still hands on, on my autocad work. your help (and that of everyone on the website) is really appreciated. Thanks !!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.