Elektrik Posted April 1, 2023 Share Posted April 1, 2023 Thanks in advance. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 2, 2023 Share Posted April 2, 2023 So if a object is on layer 1 and its color is by ByLayer, you want it now on layer2 but with color of layer 1 or if its not bylayer the color should just maintain anyway. Quote Link to comment Share on other sites More sharing options...
Elektrik Posted April 2, 2023 Author Share Posted April 2, 2023 8 hours ago, BIGAL said: So if a object is on layer 1 and its color is by ByLayer, you want it now on layer2 but with color of layer 1 or if its not bylayer the color should just maintain anyway. Yes, a object is on layer 1 and its color is by ByLayer, I want it now on layer2 but with color of layer 1. Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted April 2, 2023 Share Posted April 2, 2023 Elektrik, this VLA approach should set you in the right direction. No error trapping. (defun C:LAYER-TEST ( / doc lay suf sel lyr col ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq lay (vla-get-layers doc)) (setq suf "_1") (if (ssget) (progn (vlax-for x (setq sel (vla-get-activeselectionset doc)) (cond ((not (tblsearch "Layer" (setq lyr (strcat (vla-get-layer x) suf)))) (vla-put-color (vla-add lay lyr) (setq col (vla-get-color (vla-item lay (vla-get-layer x)))) ) (vla-put-layer x lyr) ) ( t (if (not (= (vla-get-color (vla-item lay lyr)) col)) (progn (vla-put-color (vla-item lay lyr) col) (vla-put-layer x lyr) ) ) ) ) ) (vla-delete sel) ) ) (princ) ) (princ) 1 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.