bchou Posted July 15, 2009 Posted July 15, 2009 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 =] Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 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)) Quote
bchou Posted July 15, 2009 Author Posted July 15, 2009 great stuff leemac, small code-great powers. i've just tested this out, it doesn't seem to clear out nested item? Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 Hmm... not sure then, as I think this is the only VL method for purging, without resorting to manually creating a "purge" function. Quote
VVA Posted July 15, 2009 Posted July 15, 2009 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)) Quote
Lee Mac Posted July 15, 2009 Posted July 15, 2009 Thanks VVA, I wouldn't have thought to do that Quote
bchou Posted July 15, 2009 Author Posted July 15, 2009 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)) Quote
Lee Mac Posted July 16, 2009 Posted July 16, 2009 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. Quote
bchou Posted July 16, 2009 Author Posted July 16, 2009 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? Quote
VVA Posted July 17, 2009 Posted July 17, 2009 (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) Quote
VVA Posted July 17, 2009 Posted July 17, 2009 Remark. vla-zoomextents, vla-zoomall work only with active document. http://discussion.autodesk.com/forums/message.jspa?messageID=1184966 (vla-ZoomExtents (vlax-get-acad-object)) Quote
Zorg Posted July 17, 2009 Posted July 17, 2009 ..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? Quote
Lee Mac Posted July 17, 2009 Posted July 17, 2009 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? Quote
Zorg Posted July 17, 2009 Posted July 17, 2009 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? Quote
Lee Mac Posted July 17, 2009 Posted July 17, 2009 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. Quote
Zorg Posted July 17, 2009 Posted July 17, 2009 ahh! you're all still so much more advanced than me at lisp I'll stay tuned to this thread, the lisp will be massivley useful for me whne im rebading drawings! Quote
Lee Mac Posted July 17, 2009 Posted July 17, 2009 ahh! you're all still so much more advanced than me at lisp 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)) Quote
Recommended Posts
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.