Jump to content

Recommended Posts

Posted

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 =]

Posted

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

Posted

great stuff leemac, small code-great powers.

 

i've just tested this out, it doesn't seem to clear out nested item?

Posted

Hmm... not sure then, as I think this is the only VL method for purging, without resorting to manually creating a "purge" function.

Posted

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

Posted

you guys are legends!

works wonderfully

Posted

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

Posted

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.

Posted

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?

Posted

(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

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

Posted

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?

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

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

Posted

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!

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

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