Jump to content

Lisp to clean files


NineteenHand

Recommended Posts

I recently started work at a firm which uses AutoCAD 2012. Some of the files sizes get huge and it is a problem to send them electronically or plot them. I was given a solution which greatly reduces the file size. The only problem is the time required to go through the process for each drawing. I know a lisp will reduce this time but I am not completely sure how to go about it. I have read through several webpages and many forum posts but was hoping for some input from the community. Here is the process I was given.

 

open dwg

command: audit (option: y)

command: dxfout (save to desktop)

close dwg

open dxf

command: audit (option: y)

command: purge (all)

saveas over original dwg with new file

close dxf

delete dxf

 

I know most (all?) of these processes can be automated. I am very familiar with the c language but I can find a "library"(I know this is not how AutoCAD deals with commands) with a list of commands and the modifiers associated with each. How can I automate the above process so it will execute the above commands on all dwg in a given folder?

 

Thank you for your help and for dealing with another inexperienced lisp request.

Link to comment
Share on other sites

I usually use two way to do this task.

* ETRANSMIT command.

or

*write simple script to do this task.

Edited by mostafa badran
Link to comment
Share on other sites

Not sure why your making a dxf rather than just purging if you type -purge A this will run a comand mode without any user input. Use a script

 

-purge A N

-purge R N

Audit Y

save

Link to comment
Share on other sites

Purge Regapps first then do the purge > all.

 

In my opinion you don't need to do this with a lisp routine. It can be done using a script.

Link to comment
Share on other sites

I have a LISP program (on my work computer) that I will share tomorrow. Please post a reminder!!

 

Please see the attached LISP like I discussed... I use this everyday at work and it has help my team and I with Fatal Errors

 

(defun C:FIN() (COMMAND "-PURGE" "R" "*" "N"   "-PURGE" "A" "*" "N"   "_QSAVE"   "AUDIT" "Y"   "CTAB" "000" "ZOOM" "A" "_QSAVE"))(princ)

 

**Disclaimer: I modified the code from what a Co-Worker gave me, so I do not own the original work.**

Link to comment
Share on other sites

Like post above as i suggested use -purge this is a lisp example but you can change it to a script as well and run it over as many drawings as you like just add the open dwgxxx at start. Just me I do a zoom all layout tabs as part of cleaning up, particuarly if you go down the script path, you can also set the final layout to be the first not by name if you want re "000" it does though require about 3 lines of code.

 

(vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
(if (= 1 (vla-get-taborder lay))
 (setvar "ctab" (vla-get-name lay))
) ; if
) ; for

Link to comment
Share on other sites

This is script we use to whip client files before we xref them in. I prefer a script you don't accidentally run it and it is simpler for our staff.

 

model
DELETELAYOUTS
-xref
d
*
-vports
si
-view
top
-scalelistedit
R
Y
E
regenall
-purge
r
*
n
-purge
A
*
N
'_snapang
0
zoom
e
audit
y
-purge
r
*
n
qsave
-purge
A
*
N
-purge
r
*
n
qsave

Link to comment
Share on other sites

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