Jump to content

Recommended Posts

Posted

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.

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    10

  • Lee Mac

    9

  • rodbuilder

    3

  • David Bethel

    1

Top Posters In This Topic

Posted

Perhaps you could cycle through the relevant collections and construct a comma-delimited list to feed to the purge command.

Posted

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

Posted

ah hahaha, i can't believe this works:

(command "_.-purge" "_all" "[~ALAN ALAN2 ALAN3 CAD1 CAD2 CAD3]" "_no")

Posted
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.

Posted
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:

Posted
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.

Posted

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."

Posted
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. o:)

Posted
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.

Posted
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. o:)

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.

Posted

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 :oops:

Posted
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 :oops:

 

if it's a prefix, yes. i was working on the entire name though.

Posted
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 :oops:

Posted
Ok, wasn't sure whether his were prefixes or not... I must be losing it... after working on that layer lisp :oops:

 

i was confused for a minute too, i forgot what wcmatch filtering went to what thread.

Posted

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... :(

Posted
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 8)

 

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.

Posted

(command "_.-purge" "_all" "~004" "_no") works but I cant seem to pass a list to it.

Posted
(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)
 )

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...