alanjt Posted August 22, 2009 Posted August 22, 2009 so, you want one that moves selected objects to a cloned layer suffixed with "_N", or are you wanting the written routine modified to do this? Quote
Lee Mac Posted August 22, 2009 Posted August 22, 2009 Please modifyThanks Kalarpu Kalarpu - there is no need for three copies of the same LISP, with the only difference being the suffix - just make one sub-function, with the suffix as the argument and call it as needed. :wink: Quote
kalarpu Posted August 22, 2009 Posted August 22, 2009 I have no idea because I am just start learning. Please guide me Thanks Quote
Lee Mac Posted August 22, 2009 Posted August 22, 2009 I have no idea because I am just start learning.Please guide me Thanks Not a problem, I meant like this: ;This program is produced by LEE MAC and edited by Alanjt for Kalarpu (defun lays (suff / i ss ent Nme Obj nNme) (vl-load-com) (setq lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq Nme (cdr (assoc 8 (entget ent))) Obj (vlax-ename->vla-object ent)) (cond ((and (= 14 (strlen Nme)) (wcmatch Nme "[ACELMNS ]-*")) (if (tblsearch "LAYER" (setq nNme (strcat Nme suff))) (vla-put-layer Obj nNme) (vla-put-Name (vla-item lay Nme) nNme))) ((and (< 14 (strlen Nme)) (wcmatch Nme "[ACELMNS ]-*")) (setq nNme (strcat (substr Nme 1 14) suff)) (if (tblsearch "LAYER" nNme) (vla-put-layer Obj nNme) (progn (vla-put-color (vla-add lay nNme) acwhite) (vla-put-Layer Obj nNme)))) (t (princ (strcat "\n** Layer: " Nme " is not a Standard Format")))))) (princ)) (defun c:layO ( ) (lays "") (princ)) (defun c:layE ( ) (lays "_E") (princ)) (defun c:layN ( ) (lays "_N") (princ)) (defun c:layR ( ) (lays "_R") (princ)) I have made the suffix an argument and have called the sub-function "lays" each time. Lee Quote
kalarpu Posted August 22, 2009 Posted August 22, 2009 Hi Lee Mac Please check this "(setq nNme (strcat Nme suff))" Because I think it changed(renamed) my standard layer to 14_N or 14_E or 14_R even I selected only one obj (the rest I still want to remain in standard layer). I prefer to create newlayer base on standard not for just rename. Thanks for your help Quote
Lee Mac Posted August 22, 2009 Posted August 22, 2009 At the moment the LISP is checking to see if "14_E" exists, and, if it does it will move the object to it, else it will rename the layer to "14_E", are you saying that instead of renaming, to create a new layer and move the object to this new layer? Quote
kalarpu Posted August 22, 2009 Posted August 22, 2009 Yes, please create new layer instead of renaming because I just want to move the selected obj only to new layer so that other objs still remain in old layer Thanks Quote
Lee Mac Posted August 22, 2009 Posted August 22, 2009 How about this: ;This program is produced by LEE MAC and edited by Alanjt for Kalarpu (defun lays (suff / i ss ent Nme Obj nNme) (vl-load-com) (setq lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq Nme (cdr (assoc 8 (entget ent))) Obj (vlax-ename->vla-object ent)) (cond ((and (= 14 (strlen Nme)) (wcmatch Nme "[ACELMNS ]-*")) (if (tblsearch "LAYER" (setq nNme (strcat Nme suff))) (vla-put-layer Obj nNme) (progn (vla-add lay nNme) (vla-put-Layer Obj nNme)))) ((and (< 14 (strlen Nme)) (wcmatch Nme "[ACELMNS ]-*")) (setq nNme (strcat (substr Nme 1 14) suff)) (if (tblsearch "LAYER" nNme) (vla-put-layer Obj nNme) (progn (vla-put-color (vla-add lay nNme) acwhite) (vla-put-Layer Obj nNme)))) (t (princ (strcat "\n** Layer: " Nme " is not a Standard Format")))))) (princ)) (defun c:layO ( ) (lays "") (princ)) (defun c:layE ( ) (lays "_E") (princ)) (defun c:layN ( ) (lays "_N") (princ)) (defun c:layR ( ) (lays "_R") (princ)) Quote
kalarpu Posted September 17, 2009 Posted September 17, 2009 Hi When I use refedit in place, all layer changed to $-$14 and cannot use lisp already.Please help Quote
JeepMaster Posted September 30, 2009 Posted September 30, 2009 Is it possible to modify the lisp that you guys have here so that all the layers on the drawing will have "-DD" added on the end? It seems very close to be able to do it, but I can't figure it out. ie: E-POWR-TEXT to E-POWR-TEXT-DD Quote
Lee Mac Posted September 30, 2009 Posted September 30, 2009 The lazy man's way: (defun c:laysuff (/ suff doc) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff for all Layers: ")) (snvalid suff))) (princ "\n** Invalid Suffix **")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (vl-catch-all-apply 'vla-put-Name (list lay (strcat (vla-get-Name lay) suff)))) (vla-EndUndoMark doc) (princ)) Quote
JeepMaster Posted October 1, 2009 Posted October 1, 2009 It works perfectly. Thanks LeeMac for your help as usual. How hard is it to remove suffix? so instead of vla-put-name, vla-remove-name? Sorry I don't know any VLA commands. Quote
Lee Mac Posted October 1, 2009 Posted October 1, 2009 Haha, no such function I am afraid... we have to approach things differently (defun c:RemSuff (/ suff doc) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff to Remove: ")) (snvalid suff))) (princ "\n** Invalid Suffix **")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (vl-catch-all-apply 'vla-put-Name (list lay (vl-string-right-trim suff (vla-get-Name lay))))) (vla-EndUndoMark doc) (princ)) Quote
alanjt Posted October 1, 2009 Posted October 1, 2009 You could do something like this and it wouldn't add the suffix if said suffix already existed. (ie: Lay would become Lay-DD, but Fun-DD would be left as is) (defun c:laysuff (/ suff doc) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff for all Layers: ")) (snvalid suff))) (princ "\n** Invalid Suffix **")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (or (wcmatch (strcase (vla-get-name lay)) (strcase (strcat "*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (strcat (vla-get-Name lay) suff))))) (vla-EndUndoMark doc) (princ)) Quote
Lee Mac Posted October 1, 2009 Posted October 1, 2009 Nice idea Alan - hadn't thought of it... but then I did say "lazy man's way"... Quote
JeepMaster Posted October 1, 2009 Posted October 1, 2009 Wow, LeeMac that is awsome stuff. Thanks for the super quick response. I'm running into a little problem. If only some of my layers have the suffix I wish to remove, it doesn't seem to work. ie: I have many layers with -NEWW and -EXST. And I want to remove all the -EXST from those layers. Maybe it needs to have a search function to replace those layers only. Quote
JeepMaster Posted October 1, 2009 Posted October 1, 2009 You could do something like this and it wouldn't add the suffix if said suffix already existed. (ie: Lay would become Lay-DD, but Fun-DD would be left as is) (defun c:laysuff (/ suff doc) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff for all Layers: ")) (snvalid suff))) (princ "\n** Invalid Suffix **")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (or (wcmatch (strcase (vla-get-name lay)) (strcase (strcat "*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (strcat (vla-get-Name lay) suff))))) (vla-EndUndoMark doc) (princ)) Thanks Alan. I didn't pick that one up untill I recheck all my layers. Thanks so much. 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.