mstg007 Posted January 28, 2020 Share Posted January 28, 2020 I was wondering how to select all entities on a layer and then move them to another layer via a dialog box or something. I was starting off with the basic routine that would allow me to select the objects on the layer. (defun c:sellay (/ e ) (if (setq e (nentsel "Select entity on a layer: ")) (sssetfirst nil (ssget "_X" (list (cons 8 (cdr (assoc 8 (entget (car e)))))))) ) (princ) ) But I am having trouble figuring out how to link the selection to maybe a command like "Layer Match" and use its dialog or alike. Thank you for any pointers. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 28, 2020 Share Posted January 28, 2020 (edited) After you get your selection, use MA ( Matchprop ) pick your source object, then use P ( previous ) and it will update your set. FWIW, you can shorten this up a bit by removing the unnecessary (cons 8 (cdr ... (defun c:sellay (/ e) (if (setq e (nentsel "\nSelect entity on a layer: ")) (sssetfirst nil (ssget "_X" (list (assoc 8 (entget (car e)))))) ) (princ) ) Here's another to match the layer of a picked item: (defun c:sellay (/ a b) (if (and (setq a (car (nentsel "\nSelect entity on a layer to change: "))) (setq b (car (nentsel "\nSelect entity to match layer: "))) (setq b (assoc 8 (entget b))) ) (foreach x (mapcar 'cadr (ssnamex (ssget "_X" (list (assoc 8 (entget a)))))) (entmod (subst b (assoc 8 (entget x)) (entget x))) ) ) (princ) ) Edited January 28, 2020 by ronjonp Quote Link to comment Share on other sites More sharing options...
mstg007 Posted January 28, 2020 Author Share Posted January 28, 2020 What I was trying to do; we get other drawings from other places. We usually have to "breakout" or change there dwg content to our own layers. Usually I insert our layers and then freeze them off. Use the above routine to select the entities then move them over to the correct layer. And to top that off. we usually get drawings from a lot of different places, so its usually never the same. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 29, 2020 Share Posted January 29, 2020 There is no quick way you can make a text file etc for a company using a csv file oldlayer,newlayer, just process the layers selecting and changing. Its pretty easy to dump all the layers to a text file put in say excel, handy where layer's go on one layer. Do a ssget like above use (cons 8 oldlayer) can use chprop rather than process each entity speed may come into it. (command "Chprop" ss "" "la" "newlay" "") (setq fo (open "D:\\acadtemp\\layers.txt" "w")) (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for lay lays (write-line (vla-get-name lay) fo) ) (close fo) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 29, 2020 Share Posted January 29, 2020 Why don't you make a common list of old layer / new layer and process .. I understand there are different clients but there has to be some similarities in your field? Quick example: (defun c:foo (/ s) (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for b a (setq s (strcase (vla-get-layer b) t)) (entmod (append (entget (vlax-vla-object->ename b)) (list (cons 8 ;; Update the list to what you need (cond ((wcmatch s "*walk*,*street*,*asphalt*") "hardstuff") ((wcmatch s "*chicken*,*sparrow*,*cockatoo*") "birds") ("No Match") ) ) ) ) ) ) ) (princ) ) There is also LAYTRANS which may do a bulk of the work for you: Quote Link to comment Share on other sites More sharing options...
mstg007 Posted January 29, 2020 Author Share Posted January 29, 2020 I think I can use the wildcard catch to get most of the non standard layers to standard layers using your above method. Some of these drawings have a ton of layers. I think this will help to speed things up as going through the non standard drawing. With the remaining that it cannot find, I can manually move it over like I mentioned earlier. Let me play around with this idea. Thank you for the input! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted January 29, 2020 Share Posted January 29, 2020 1 hour ago, mstg007 said: I think I can use the wildcard catch to get most of the non standard layers to standard layers using your above method. Some of these drawings have a ton of layers. I think this will help to speed things up as going through the non standard drawing. With the remaining that it cannot find, I can manually move it over like I mentioned earlier. Let me play around with this idea. Thank you for the input! Glad to help. Quote Link to comment Share on other sites More sharing options...
KraZeyMike Posted March 26, 2023 Share Posted March 26, 2023 (edited) On 1/29/2020 at 10:31 AM, ronjonp said: Why don't you make a common list of old layer / new layer and process .. I understand there are different clients but there has to be some similarities in your field? Quick example: (defun c:foo (/ s) (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for b a (setq s (strcase (vla-get-layer b) t)) (entmod (append (entget (vlax-vla-object->ename b)) (list (cons 8 ;; Update the list to what you need (cond ((wcmatch s "*walk*,*street*,*asphalt*") "hardstuff") ((wcmatch s "*chicken*,*sparrow*,*cockatoo*") "birds") ("No Match") ) ) ) ) ) ) ) (princ) ) Hi Ronjonp, This is exactly what I am trying to do without using the layer translation table. My command looks like the following: (defun c:HPO (/ s) (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for b a (setq s (strcase (vla-get-layer b) t)) (entmod (append (entget (vlax-vla-object->ename b)) (list (cons 8 (cond ((wcmatch s "*Building*") "HPO-Building") ((wcmatch s "*Outdoor*") "HPO-Outdoor") ((wcmatch s "*Setout*,*Offset*") "HPO-Setout") ((wcmatch s "*Bdy*,DP*,CP*,Stage*") "Bdy") ("No Match" ) ) ) ) ) ) ) (princ) ) Running the command doesn't work. Edited March 27, 2023 by SLW210 Added Code Tags! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 27, 2023 Share Posted March 27, 2023 (edited) Wcmatch is case sensitive. This returns all lower case ( t ) : (setq s (strcase (vla-get-layer b) t)) And in your check you have a mix of case: (wcmatch s "*Building*") so make them all lower case and it should work. Edited March 27, 2023 by ronjonp Quote Link to comment Share on other sites More sharing options...
KraZeyMike Posted March 27, 2023 Share Posted March 27, 2023 Thanks for getting back to me, I should've been a bit more specific, I can't actually get the command to run. Typing the Defun command does not register, nor does it show in the dynamic input that such a command exists, even after I have loaded the lisp and restarted Acad. Thanks for your help 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.