baker Posted August 31, 2011 Share Posted August 31, 2011 I have a drawing i need to simply change the leading letters of the layer (C-***) to V-***. anyway to Find and Replace? Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 Look at the RENAME command. C-* to V-* Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 Try this baker and it is case sensitive which means ( c- (small letter) is not equal to C- (capital letter)) . Codes better than Command calls . (defun c:TesT (/ nxt layrs Nme) ;; == TharwaT 01. 09. 2011 == ;; (while (setq nxt (tblnext "LAYER" (null nxt))) (setq layrs (entget (tblobjname "LAYER" (setq Nme (cdr (assoc 2 nxt))))) ) (if (and (not (eq Nme "0")) (eq (vl-string-search "C-" Nme 0) 0) ) (entmod (subst (cons 2 (vl-string-subst "V-" "C-" (cdr (assoc 2 layrs)))) (assoc 2 layrs) layrs ) ) ) ) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 1, 2011 Share Posted September 1, 2011 (eq (vl-string-search "C-" Nme 0) 0) *cough* wcmatch *cough* But I try not to re-invent the wheel where possible Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 *cough* wcmatch *cough*But I try not to re-invent the wheel where possible I have thought of that as another access to Layer name matches and I do agree that the function wcmatch is much better than vl-string-search in this case . Anyway here it goes . Comments are also welcomed . (defun c:TesT (/ nxt layrs Nme) ;; == TharwaT 01. 09. 2011 == ;; (while (setq nxt (tblnext "LAYER" (null nxt))) (setq layrs (entget (tblobjname "LAYER" (setq Nme (cdr (assoc 2 nxt))))) ) (if (and (not (eq Nme "0")) (wcmatch Nme "C-*") ) (entmod (subst (cons 2 (vl-string-subst "V-" "C-" (cdr (assoc 2 layrs)))) (assoc 2 layrs) layrs ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 1, 2011 Share Posted September 1, 2011 Tharwat, Not that you have to of course, but out of curiosity... if you're not going to use the RENAME command, and you're going to use vl-* functions, then why not just iterate the Layers Collection instead? Pseudo code: ((lambda (acDoc / ) (vlax-for lay (vla-get-layers acDoc) [color=seagreen];;<-- Check / rename layers here[/color] ) ) (vla-get-activedocument (vlax-get-acad-object))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 .. if you're not going to use the RENAME command, If you have many layers (maybe Hundreds) in a dwg , the command call would be lazy . and you're going to use vl-* functions, then why not just iterate the Layers Collection instead? Both are the same , aren't they ? One more routine in Vl . (defun c:TesT (/ lays Nme) ;; == TharwaT 01. 09. 2011 == ;; (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)) ) ) (vlax-for x lays (if (wcmatch (setq Nme (vla-get-name x)) "C-*") (vla-put-name x (vl-string-subst "V-" "C-" Nme)) ) ) (princ) ) Regards, Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 Codes better than Command calls . Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 I have forgotten that Multiple Selection method is allowed in Rename Command . Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 I have forgotten that Multiple Selection method is allowed in Rename Command . Work smart, not hard. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 Work smart, not hard. Nice saying . When being overwhelmed by lots of projects to hand over on time , there won't be time to spend on thinking than keep on working (sometimes) Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 Nice saying . When being overwhelmed by lots of projects to hand over on time , there won't be time to spend on thinking than keep on working (sometimes) Then maybe you should spend more time working and less time trolling the forums. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 1, 2011 Share Posted September 1, 2011 There must a few seconds to get some fresh air , to be able to carry on and to keep the brain a live . Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 There must a few seconds to get some fresh air , to be able to carry on and to keep the brain a live . Quick, step outside. Quote Link to comment Share on other sites More sharing options...
baker Posted September 1, 2011 Author Share Posted September 1, 2011 I am an idiot!!! thank you guys for being patient and supportive!! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 1, 2011 Share Posted September 1, 2011 I am an idiot!!! thank you guys for being patient and supportive!! *US* We'll whip you numpties into shape, one way or another! LoL ^^ Just being sarcastic, of course. Please take no offense. Quote Link to comment Share on other sites More sharing options...
baker Posted September 1, 2011 Author Share Posted September 1, 2011 none taken.. i own a VW enthusiasts forum and we toss poo at each other all the time!! all in good fun! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 1, 2011 Share Posted September 1, 2011 none taken.. i own a VW enthusiasts forum and we toss poo at each other all the time!! all in good fun! ^^ Gold, that is. I'm glad you share the sense of humor; you *should* fit in nicely. Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 1, 2011 Share Posted September 1, 2011 Man, this thread seems to have take a sh!77y direction and done down the toilet. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 1, 2011 Share Posted September 1, 2011 Man, this thread seems to have take a sh!77y direction and done down the toilet. I hate it when things 'done down the toilet'. 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.