au-s Posted January 22, 2010 Posted January 22, 2010 hi, I have those two lisps that somehow can't work. I want this lisp to work on chosen dwg-files. The batch process is going on and doing great (I applied it to other lisps) but somehow it is now zooming Extents and not saving the file. Problems: 1. The lisp is not Zooming out. 2. If I uncomment qsave command the batch process stops after one drawing. here are the codes, Lisp1 (defun rensatabortxr () (command "_xref" "D" "*") (command "_.zoom" "e") ;(command "_qsave") (princ) ) (defun c:AIX:rensatabortxr () (rensatabortxr) (princ)) Lisp2, batch process: (defun c:AIX:RENSAXRMULTI (/ flag thelist thedir nfiles thefile fn ctr dname) ;set the flag (setq flag T) ;check Doslib is loaded (if (not (member "doslib17.arx" (arx))) (progn (if (findfile "doslib17.arx") (arxload "doslib17") (progn (alert "DosLib not installed") (setq flag nil) );progn );if );progn );if ;if DosLib is installed and loaded (if flag ;do the following (progn (setq thelist (dos_getfilem "Välj Filer:" "" "DWG Files (*.dwg)|*.dwg")) ;retrieve the directory (setq thedir (car thelist)) ;retrieve the file names (setq thelist (cdr thelist)) ;get the number of files (setq nfiles (length thelist)) (setq thefile (strcat (dos_tempdir) "temp.scr")) (setq fn (open thefile "w")) (setq ctr 0) (repeat nfiles (setq dname (nth ctr thelist)) (write-line (strcat "open \"" thedir dname "\" (load \"K:/CAD/AIX-meny-2008/Lisp/_cadans/rensa_tabortxreffar.lsp\") (c:AIX:rensatabortxr) close \"Y\"") fn) (setq ctr (1+ ctr)) );end repeat (close fn) (setvar "cmdecho" 0) (setvar "filedia" 0) (command "_script" thefile) (setvar "filedia" 1) (princ "\n<!> KLART! <!>") );; end progn );; end if (princ) );;; end defun Quote
Lee Mac Posted January 22, 2010 Posted January 22, 2010 Hi Au-S, Perhaps take a look at this: http://www.cadtutor.net/forum/showpost.php?p=295487&postcount=23 You could also try this as your LISP: (defun rensatabortxr (/ doc app) (vl-load-com) (vlax-for obj (vla-get-Blocks (setq doc (vla-get-ActiveDocument (setq app (vlax-get-acad-object))))) (if (eq :vlax-true (vla-get-isXref obj)) (vla-detach obj))) (vla-ZoomExtents app) (vla-save doc) (princ)) In the Script: _.open *file* (load "K:\\CAD\\AIX-meny-2008\\Lisp\\_cadans\\rensa_tabortxreffar.lsp") (rensatabortxr) _.close Hope this helps, Lee Quote
au-s Posted January 25, 2010 Author Posted January 25, 2010 Hi, hehe ... that qsave issue gets on my nerve. It seems that if I uncomment qsave it runs allthough it closes the file but it cant save it. if I have qsave command in the lisp or in the batch lisp it doesnt continue ... LeeMac: Your script write lisp is okay allthough users at my office cant write the script. The above batch lisp writes the script automatically. Quote
Lee Mac Posted January 25, 2010 Posted January 25, 2010 Hi, hehe ... that qsave issue gets on my nerve. It seems that if I uncomment qsave it runs allthough it closes the file but it cant save it. if I have qsave command in the lisp or in the batch lisp it doesnt continue ... LeeMac: Your script write lisp is okay allthough users at my office cant write the script. The above batch lisp writes the script automatically. So does it work now? Did the VL alternative LISP perform better? Just thought the Script Writer would be better for generic purposes - save you re-writing your script writing LISP everytime. There's always time for your users to learn scripting... it really isn't too difficult Quote
au-s Posted January 25, 2010 Author Posted January 25, 2010 No, it does not work if I have the save row. If I comment it out it goes round open and close chosen drawings. Itried also to apply qsave to the batch lisp but with no luck. If I do have the save command in your lisp: vla-save doc and if I modify the batch lisp with : (strcat "open \"" thedir dname "\" (load \"K:/CAD/AIX-meny-2008/Lisp/_cadans/rensa_tabortxreffar.lsp\") (rensatabortxr) " ) Then the lisp actually saves and batch runs it BUT it always opens the HELP files and does not close the dwg files your lisp runs on. So if I choose to open 20 files it will not close them but THEN the lisp works So that my progress so far ... The good thing about this batch lisp (there are many I presume) is that I can apply it to different lisps and the src file always is overwritten in a tempDir. So if you choose to run this or that lisp and batch run it you do not need to think about issues like, file save location or similiar... Quote
Lee Mac Posted January 25, 2010 Posted January 25, 2010 Perhaps try this instead: (defun rensatabortxr (/ doc app) (vl-load-com) (vlax-for obj (vla-get-Blocks (setq doc (vla-get-ActiveDocument (setq app (vlax-get-acad-object))))) (if (eq :vlax-true (vla-get-isXref obj)) (vla-detach obj))) (vla-ZoomExtents app) (vla-saveas doc (vla-get-FullName doc)) (princ)) And close the drawing with a call in the script. Quote
au-s Posted January 25, 2010 Author Posted January 25, 2010 Hmm ... I think I have done it... I tried like this: (strcat "open \"" thedir dname "\" (load \"K:/CAD/AIX-meny-2008/Lisp/_cadans/rensa_tabortxreffar.lsp\") (rensatabortxr) _.close" "" ) Then it is okay. Saves and detaches all xrefs and all that .. Yiipie! LeeMac: Thanx for the help Sir! But now it seems to work. Quote
Lee Mac Posted January 25, 2010 Posted January 25, 2010 You're welcome, glad you got it working in the end Quote
au-s Posted January 25, 2010 Author Posted January 25, 2010 Yeah, I just realized that objectDBX can do stuff like that without opening drawings? Do you know some good site that explains how to make an objectDBX & vlisp code to process a certain lisp like the batchprocess above. You just apply the lisp you want to be processed. Quote
Lee Mac Posted January 25, 2010 Posted January 25, 2010 True, ObjectDBX can do all the above, an 100x faster also. But there are drawbacks: Drawing Thumbnail is lost upon saving - unless Arx/.NET is used. Cannot use SelectionSets Cannot use Ent* methods. I'm not sure of too many sites that will explain it too well, this does a good job though: http://augiru.augi.com/content/library/au07/data/paper/CP311-4.pdf 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.