rodbuilder Posted August 21, 2009 Posted August 21, 2009 I need some help writing a lisp for a purge. I want to purge everything in the drawing except certain blocks, layers, and dimension styles. I have tried to think of a way to filter them out but I just cant. I was thinking if I could pass the names back from the purge command then I can make a list for the routine to check by while purging. Anyone have any ideas. Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 Perhaps you could cycle through the relevant collections and construct a comma-delimited list to feed to the purge command. Quote
David Bethel Posted August 21, 2009 Posted August 21, 2009 The only way I can think of is to reference the BLOCK, LAYER or DIMSTYLE into an empty BLOCK that has been inserted. That way purge sees it as referenced. But it could drive some people down the road nuts trying to figure out where they are. -David Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 ah hahaha, i can't believe this works: (command "_.-purge" "_all" "[~ALAN ALAN2 ALAN3 CAD1 CAD2 CAD3]" "_no") Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 So the purge entry functions using a wildcard system? Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 So the purge entry functions using a wildcard system? beats creating a list of names not to purge and a list of everything, then iterating through the everything list, puring anything that isn't a member of the ignore list. at least this way, you only have to make an ignore list/string......better than nothing. Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 beats creating a list of names not to purge and a list of everything, then iterating through the everything list, puring anything that isn't a member of the ignore list. at least this way, you only have to make an ignore list/string......better than nothing. Oh I agree - a much better solution. Mine was just going to be a few sets of a conditional within a vlax-for... :wink: Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 Oh I agree - a much better solution. Mine was just going to be a few sets of a conditional within a vlax-for... :wink: that might be the better option. i will plead ignorance on using vla for purging. since i've only performed a purge all with vla in my code before, i just haven't had the need to research it beyond purge all. Quote
rodbuilder Posted August 21, 2009 Author Posted August 21, 2009 I could not get (command "_.-purge" "_all" "[~012 016 024 REV-TRi]" "_no") to work. 012, 016, 024 are dimension layers and REV-TRi is a block. it says "No unreferenced multileader styles found." Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 that might be the better option. i will plead ignorance on using vla for purging. since i've only performed a purge all with vla in my code before, i just haven't had the need to research it beyond purge all. I too have only used vla-PurgeAll, and AFAIK there is only PurgeAll and PurgeFitData (for Splines). I was going down the road of creating a command delimited list within the vlax-for loop, then just using the command version. Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 I could not get (command "_.-purge" "_all" "[~012 016 024 REV-TRi]" "_no") to work. 012, 016, 024 are dimension layers and REV-TRi is a block. it says "No unreferenced multileader styles found." odd, worked on my machine fine. well, poop. back to the drawing board. Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 I too have only used vla-PurgeAll, and AFAIK there is only PurgeAll and PurgeFitData (for Splines). I was going down the road of creating a command delimited list within the vlax-for loop, then just using the command version. i knew there was one more, and i didn't think it was what i wanted it to be. glad to know. your option is going to be the only real choice it seems. i wonder if, after the string is compiled, will command purge accept a string that long. Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 TBH, I'm really bad with wcmatch, and never know the codes to use, but if prefixed, should it be this instead? "[~ABC DEF GHI][color=Red][b]*[/b][/color]" Or am I completely barking up the wrong tree Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 TBH, I'm really bad with wcmatch, and never know the codes to use, but if prefixed, should it be this instead? "[~ABC DEF GHI][color=Red][b]*[/b][/color]" Or am I completely barking up the wrong tree if it's a prefix, yes. i was working on the entire name though. Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 if it's a prefix, yes. i was working on the entire name though. Ok, wasn't sure whether his were prefixes or not... I must be losing it... after working on that layer lisp Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 Ok, wasn't sure whether his were prefixes or not... I must be losing it... after working on that layer lisp i was confused for a minute too, i forgot what wcmatch filtering went to what thread. Quote
Lee Mac Posted August 21, 2009 Posted August 21, 2009 Talking of wcmatch, would you know where I could find some good reference for how to use it? The VLIDE help files only give so much... Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 Talking of wcmatch, would you know where I could find some good reference for how to use it? The VLIDE help files only give so much... (princ "\n # - Matches any single numeric digit.") (princ "\n @ - Matches any single alphabetic character.") (princ "\n . - Matches any single nonalphanumeric character.") (princ "\n * - Matches any character sequence, including an ") (princ "\n empty one, and it can be used anywhere in the ") (princ "\n search pattern at the beginning, middle, or end.") (princ "\n ? - Matches any single character \n") (princ "\n ~ - If it is the first character in the pattern,") (princ "\n it matches anything except the pattern.") (princ "\n [...] - Matches any one of the characters enclosed.") (princ "\n [~...] - Matches any single character not enclosed.") (princ "\n - - Used inside brackets to specify a range.") (princ "\n for a single character.") (princ "\n , - Separates two patterns.") even in code form i wonder if i should have been putting in a comma instead of spaces. [~NAME1,NAME2,NAME3,NAME4] or maybe [~NAME1],[~NAME2],[~NAME3], i don't know and i've already shut down autocad. my project is submitted and i'm going home. i'm sure i'll be on later. Quote
rodbuilder Posted August 21, 2009 Author Posted August 21, 2009 (command "_.-purge" "_all" "~004" "_no") works but I cant seem to pass a list to it. Quote
alanjt Posted August 21, 2009 Posted August 21, 2009 (command "_.-purge" "_all" "~004" "_no") works but I cant seem to pass a list to it. i don't get it, i just created a bunch of layers and blocks, ran this and it worked perfectly. (defun c:G (/ string) (setq string "[~ALAN1 ALAN2 ALAN3 ALAN4 ALAN5 1 2 3 4 A B C D GOOD BAD]") (command "_.-purge" "_all" string "_no") (princ) ) 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.