Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

wblock in and out of lisp

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
srestmeyer
1376 Views, 26 Replies

wblock in and out of lisp

Hi all,

 

I am running -wblock in a drawing to clean it up and reduce the file size. By doing this it brings the file size down from over 9 meg to just over 1 meg by removing unused blocks that are not able to be purged out of the drawing using the purge all command.

 

My problem is, when I run the -wblock manually at the command prompt it works fine. But, when I run it inside a simple lisp routine

 

^C^C^P(command "-wblock" (strcat (getvar "dwgprefix") "CLEAN_" (getvar "dwgname"))"*") ^P^C^C

 

It appears to work fine without errors. It creates the new file with the correct file name. But it only reduces the same file size to just over 8 meg

 

Any ideas?

 

Thank in advance

Scott

26 REPLIES 26
Message 21 of 27
srestmeyer
in reply to: Jason.Piercey

wow. I'm seeing what I sent you.

Was the dictionary deleted? How do you check? Is that a table search?

 

 

Scott

Message 22 of 27
srestmeyer
in reply to: Jason.Piercey

I just ran the commands manually and I got the same results as you

 

(dictremove (namedobjdict) "ACAD_DGNLINESTYLECOMP")
       (command "purge" "a" "*" "n")
 (command "._qsave")

 

But when I run it in a lisp program it doesn't work, even though I don't get errors.

 

Message 23 of 27
Jason.Piercey
in reply to: srestmeyer

The file you attached was bout 8.7mb before deleting the dictionary and purging.  1.9mb after.  Is that not what you are seeing?

 

As for checking to see if the dictionary exists, one way to do it would be with the following.

 

(listdicts)

 

 

(defun listdicts ()
 (cdrs 3 (entget (namedobjdict)))
 )


; [key] - 1st element in a pair
; [lst] - list of pairs
; returns cdr of each item in [lst]
; whose car is equal to [key]
(defun cdrs (key lst / rtn)
 (foreach x lst
  (if (= key (car x))
   (setq rtn (cons (cdr x) rtn))
   )
  )
 (reverse rtn)
 )

 

Message 24 of 27
Jason.Piercey
in reply to: srestmeyer


@srestmeyer wrote:

I just ran the commands manually and I got the same results as you

 

(dictremove (namedobjdict) "ACAD_DGNLINESTYLECOMP")
       (command "purge" "a" "*" "n")
 (command "._qsave")

 

But when I run it in a lisp program it doesn't work, even though I don't get errors.

 


I am unable to replicate that behavior.

Message 25 of 27
srestmeyer
in reply to: Jason.Piercey

So it's something on my end. I'll keep looking.

 

Thanks

Scott

Message 26 of 27
srestmeyer
in reply to: Jason.Piercey

I found it. There was a variable that was nil so it wasn't running that part of the code.

 

Thanks again for all your help.

 

Scott

Message 27 of 27
Jason.Piercey
in reply to: srestmeyer

Glad you found the solution.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost