alanjt Posted October 1, 2009 Share Posted October 1, 2009 Just noticed your links to your programs in the sig.... seems like everyone followed me on that one :wink: Buzzard, Freerefill... now you... Yeah, it's just random crap, but someone might find it useful. Thought I'd stick it there so people can have a chance of giving it a look. Never know when it might be useful to someone else. I'm sure it's a waste of time and space. More than anything, I just wanted to remove the need to post a subroutine (if it's in the sub thread) everytime I post something for someone. This way, I can just post the main and direct them to the link. After that, I just added a few more, just because. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 Yeah, I think its a good idea - I would post some, but I have thousands stored and haven't got the time for any spring cleaning now... Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted October 1, 2009 Share Posted October 1, 2009 What about something like this? (defun c:RemSuff (/ suff doc name) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff to Remove: ")) (snvalid suff) ) ;_ and ) ;_ not (princ "\n** Invalid Suffix **") ) ;_ while (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ vla-get-ActiveDocument ) ;_ setq ) ;_ vla-StartUndoMark (vlax-for lay (vla-get-layers doc) (if (wcmatch (strcase (setq name (vla-get-name lay))) (strcase (strcat "*" suff)) ) ;_ wcmatch (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T) ) ;_ substr ) ;_ list ) ;_ vl-catch-all-apply ) ;_ if ) ;_ vlax-for (vla-EndUndoMark doc) (princ) ) ;_ defun Alan, Your lisp works great, and I think you for it. But my problem now is all the xref layers that's on the dwg also get the suffix added to it. Obviously, we don't want that to happen. I only want my current drawing layers to have suffix added on. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 Try this buddy: (defun c:laysuff (/ suff doc) (vl-load-com) (setq suff (getstring t "\nSpecify Suffix for all layers: ")) (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 Link to comment Share on other sites More sharing options...
JeepMaster Posted October 1, 2009 Share Posted October 1, 2009 Oh snap. That works perfect. THANK YOU!!!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 Oh snap. That works perfect. THANK YOU!!!! No probs, I edited it so you could have a space Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 Perhaps this for the removal: (defun c:RemSuff (/ suff doc name) (vl-load-com) (setq suff (getstring t "\nSpecify Suff to Remove: ")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (and (wcmatch (strcase (setq name (vla-get-name lay))) (strcase (strcat "~*|*,*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T)))))) (vla-EndUndoMark doc) (princ)) Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 1, 2009 Share Posted October 1, 2009 Yeah, I think its a good idea - I would post some, but I have thousands stored and haven't got the time for any spring cleaning now... Well, it's just some random stuff I use. I was bored and thought I'd share. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 1, 2009 Share Posted October 1, 2009 Alan,Your lisp works great, and I think you for it. But my problem now is all the xref layers that's on the dwg also get the suffix added to it. Obviously, we don't want that to happen. I only want my current drawing layers to have suffix added on. I didn't even consider Xrefs, but I see Lee took care of it. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 I didn't even consider Xrefs, but I see Lee took care of it. Had to remove all your formatting comments too... Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 1, 2009 Share Posted October 1, 2009 Had to remove all your formatting comments too... Yeah, you like that scrunched up look. :wink: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2009 Share Posted October 1, 2009 Yeah, you like that scrunched up look. :wink: I just find it easier to read "Coding styles are like a**holes, everyone has one and no one likes anyone elses." Eric Warmenhoven Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 1, 2009 Share Posted October 1, 2009 I just find it easier to read "Coding styles are like a**holes, everyone has one and no one likes anyone elses." Eric Warmenhoven LoL See, I find it easier to read with my formatting. It's just a matter of preference. Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted October 1, 2009 Share Posted October 1, 2009 Perhaps this for the removal: (defun c:RemSuff (/ suff doc name) (vl-load-com) (setq suff (getstring t "\nSpecify Suff to Remove: ")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (and (wcmatch (strcase (setq name (vla-get-name lay))) (strcase (strcat "~*|*,*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T)))))) (vla-EndUndoMark doc) (princ)) Lee, This one seems like it's still renaming xref layers. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 2, 2009 Share Posted October 2, 2009 Lee,This one seems like it's still renaming xref layers. Try this: (defun c:RemSuff (/ suff doc name) (vl-load-com) (setq suff (getstring t "\nSpecify Suff to Remove: ")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (and (not (wcmatch (setq name (vla-get-name lay)) "*|*")) (wcmatch (strcase name) (strcase (strcat "*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T)))))) (vla-EndUndoMark doc) (princ)) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 2, 2009 Share Posted October 2, 2009 Lee,This one seems like it's still renaming xref layers. When you reopen the drawing the xref layers should not be renamed. Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 2, 2009 Share Posted October 2, 2009 When you reopen the drawing the xref layers should not be renamed. I was wondering about that. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 2, 2009 Share Posted October 2, 2009 Hmm... I thought my wcmatch had covered it - but maybe not - thanks Alan. Quote Link to comment Share on other sites More sharing options...
JeepMaster Posted October 2, 2009 Share Posted October 2, 2009 I don't know what happen here, but the latest one doesn't seem to pick the correct suffix to remove. It just remove all of them. ie: when I ask it to remove "-DEMO" It removes all the layers with "-DEMO" as well as "-TEXT" defun c:RemSuff (/ suff doc name) (vl-load-com) (setq suff (getstring t "\nSpecify Suff to Remove: ")) (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for lay (vla-get-layers doc) (and (not (wcmatch (setq name (vla-get-name lay)) "*|*")) (wcmatch (strcase name) (strcase (strcat "*" suff))) (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T)))))) (vla-EndUndoMark doc) (princ)) If we back track a little, this code from Alan works just fine. The problem we had was it also renames the xrefs, but the xref layers goes back to the correct names after the drawing is reopened. So infact it actually works like it should. What about something like this? (defun c:RemSuff (/ suff doc name) (vl-load-com) (while (not (and (setq suff (getstring "\nSpecify Suff to Remove: ")) (snvalid suff) ) ;_ and ) ;_ not (princ "\n** Invalid Suffix **") ) ;_ while (vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ;_ vla-get-ActiveDocument ) ;_ setq ) ;_ vla-StartUndoMark (vlax-for lay (vla-get-layers doc) (if (wcmatch (strcase (setq name (vla-get-name lay))) (strcase (strcat "*" suff)) ) ;_ wcmatch (vl-catch-all-apply 'vla-put-Name (list lay (substr name 1 (vl-string-position (ascii suff) name nil T) ) ;_ substr ) ;_ list ) ;_ vl-catch-all-apply ) ;_ if ) ;_ vlax-for (vla-EndUndoMark doc) (princ) ) ;_ defun I actually have a xref reload lisp that will fix this problem without having to reopen the drawing. We came to this similar problem on a different lisp routine of renaming xrefs and I had the same solution of reloading all the loaded xrefs. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 2, 2009 Share Posted October 2, 2009 Mine only differs to Alan's previous one by 1 line, the line that checks for XRef layers... so not sure what is going on there... 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.