CAD2005 Posted December 21, 2024 Posted December 21, 2024 (edited) I wish there was a lisp to change the layer name, just change the name. and I found lee-mac's lisp but can't use it. I want to change the old layer name to the new layer name, like the rename command. Thank you (defun c:layren ( / enx obj old new ) (setq old "Layer_to_be_Renamed" new "New_Layer_Name" ) (if (and (setq obj (tblobjname "layer" old)) (setq enx (entget obj)) ) (entmod (subst (cons 2 new) (assoc 2 enx) enx)) ) (princ) ) Edited December 22, 2024 by CADTutor Quote
Emmanuel Delay Posted December 23, 2024 Posted December 23, 2024 That code works perfectly. So, if you have a layer named "Layer_to_be_Renamed" then the script will change the layer name to "New_Layer_Name". The question is: what would you like the code to do exactly? Do you want to type the old layer, then type the new layer? Here's what you could do: Command LAYREN1 ;; type old layer name, then type new layer name (defun c:layren1 ( / old new ) (layren (setq old (getstring "\nOld layer name: ")) (setq new (getstring "\nNew layer name: "))) (princ) ) (defun layren ( old new / enx obj ) (if (if (and (setq obj (tblobjname "layer" old)) (setq enx (entget obj)) ) (entmod (subst (cons 2 new) (assoc 2 enx) enx)) ) (progn (princ (strcat "\nLayer \"" old "\" got renamed to \"" new "\"" )) ) ) ) But again, what do you want the code to do? How do you want it to work? 1 Quote
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.