Jump to content

Purge-all Lisp similar to SaveAll & CloseAll


bchou

Recommended Posts

Hi All,

normally i try to search out a lisp instead of doing a request, but i've been having much trouble. unlike the direction from cadaysts-directory cleanup. im in search for one that would do a purge all on all the current drawings open, (mentioned above) similar to what the Express tools offer, Saveall and Closeall command.

 

Thanks =]

Link to comment
Share on other sites

Not sure if this would work?

 

(defun c:purgeall ()
 (vl-load-com)
 (vlax-for doc (vla-get-Documents
                 (vlax-get-acad-object))
   (vla-purgeall doc))
 (princ))

Link to comment
Share on other sites

From my experience: 3 times are quite enough

(defun c:purgeall ()
 (vl-load-com)
 (vlax-for doc (vla-get-Documents
                 (vlax-get-acad-object))
   [color="Red"](repeat 3 (vla-purgeall doc)))[/color]
 (princ))

Link to comment
Share on other sites

how would you do the same with zoom extents?

this is what i tried to modify the script above. i think i've created a autocad blasphemy

 

(defun c:zoomeall()(command "zoom" "e"))

(vl-load-com)

(vlax-for doc (vla-get-Documents

(vlax-get-acad-object))

(vla-zoomeall doc))

(princ))

Link to comment
Share on other sites

Zoom extents:

 

(defun c:zoomext  ()
 (vl-load-com)
 (vlax-for doc  (vla-get-Documents
                  (vlax-get-acad-object))
   (vla-zoomextents doc))
 (princ))

 

PS. you spelt "ZoomAll" wrong.

Link to comment
Share on other sites

i've tested this code and it gave me an error

 

"error: ActiveX Server returned the error: unknown name: ZoomExtents"

 

is their something im missing in the cui?

Link to comment
Share on other sites

(defun c:zoomeall ()
 (vl-load-com)
 (vlax-for doc (vla-get-documents
                 (vlax-get-acad-object)
               ) ;_ end of vla-get-Documents
   (vla-zoomextents doc)
   (vla-zoomall doc)
 ) ;_ end of vlax-for
 (princ)
) ;_ end of defun

To find the name vla function, use autocompletion

In Visual lisp editor type vla-zoom, then press Ctrl + Shift + Space (see attach)

zoom.jpg

Link to comment
Share on other sites

..would do a purge all on all the current drawings open, (mentioned above) similar to what the Express tools offer, Saveall and Closeall command.

 

Thanks =]

 

So one command that will purge all open drawings, save them and then close them? Can you fit that all into one Lisp? If so, could you also add in zoom extents on all drawings before save?

Link to comment
Share on other sites

Not sure about the ZoomExtents, as VVA points out above, but the rest I think we can do.

 

> VVA,

 

As an aside, could you not use vla-activate to make the doc the current drawing, then use vla-zoomextents?

Link to comment
Share on other sites

Not sure about the ZoomExtents, as VVA points out above, but the rest I think we can do.

 

> VVA,

 

As an aside, could you not use vla-activate to make the doc the current drawing, then use vla-zoomextents?

 

Wouldn't you then also have to specify the document which to make active? :?

Link to comment
Share on other sites

Wouldn't you then also have to specify the document which to make active? :?

 

No, we are using vlax-for to cycle through the documents collection. :)

Link to comment
Share on other sites

ahh! you're all still so much more advanced than me at lisp :ouch:

 

I'll stay tuned to this thread, the lisp will be massivley useful for me whne im rebading drawings!

Link to comment
Share on other sites

ahh! you're all still so much more advanced than me at lisp :ouch:

 

No worries, you'll get there. :)

 

Try this mate:

 

{Obviously won't close the active drawing}

 

(defun c:purgeall ()
 (vl-load-com)
 (vlax-for doc (vla-get-Documents
                 (vlax-get-acad-object))
   (repeat 3 (vla-purgeall doc))
   (if (not (eq "" (vla-get-FullName doc)))
     (vla-save doc)
     (vla-saveas doc
       (strcat
         (vla-get-Path doc) "\\"
           (vla-get-name doc))))
   (vl-catch-all-apply
     (function
       (lambda ( )
         (vla-close doc :vlax-false)))))
 (princ))

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