el_MI Posted September 19, 2011 Posted September 19, 2011 I have a LISP routine that opens a drawing related to the drawing already open, and another one that performs some layer manipulation in the 2nd drawing, does a COPYALL, and closes the 2nd drawing. What I haven't been able to figure out, through vast amount of internet searching along with trial and error, is how to be able to return to the original drawing and paste the contents. I can, of course, do it manually, but I'd like to automate it as much as possible. I've tried various lisp and script routines, also nested variations of those. The result is either a process halts due to the file opening, or a script or lisp doesn't wait for the previous one to complete before it runs. Does what I'm trying to do even sound possible??? If so, any light that can be shed on this would be greatly appreciated. Thanks. Quote
Tharwat Posted September 19, 2011 Posted September 19, 2011 Welcome to the forum . I guess you need the function *vla-activate* which would activate the needed drawing . Regards, Tharwat Quote
el_MI Posted September 20, 2011 Author Posted September 20, 2011 (edited) Tharwat, Thanks for your help. I have added four lines of code related to vla-activate, as suggested, but the results are still the same. (defun c:GS (/ dwgPath dwgList dwgName numDwgs count scrFile) (setq dxfPath "C:\\Documents and Settings\\el_MI\\my documents\\auto_lisp\\tests\\" ; sets the path dwgList (vl-directory-files dxfPath "*.dwg") ; get the list of all the dxf's ) (if dwgList ; if dwg files exists there (progn (setq numDwgs (length dwgList) ; number of drawings count 0 ; initiate counter scrFile (open (strcat dxfPath "Runme.scr") "w") ; open a script file in the same folder ) (repeat numDwgs ; for all the drawings (setq dwgName (strcat "\"" dxfpath (nth count dwgList) "\"")) (write-line ".Open" scrFile) ; write to script file (write-line dwgName scrFile) (write-line ".delay 500" scrFile) ;;;If you need to load a lisp routine in each dwg ; (write-line "(load \"OutlineLayer.LSP\")" scrFile) ; load any required lisp routine ;;; Enter your commands here. (write-line "(c:ol)" scrFile) (write-line ".delay 500" scrFile) ;;; (setq count (1+ count)); next dwg ) (close scrFile) ; close when done (command ".script" (strcat dxfpath "Runme.scr")) ; run the script ); progn ); if ;(setq documents (vla-get-documents (vlax-get-acad-object))) ;(setq DwgFile "373_0001.dwg") ;(setq doc1 (vla-item documents DwgFile)) ;(vla-activate doc1) (command ".pasteorig") (princ) ) ; defun Any commands following the script write/run are executed immediately, without waiting for the script to complete. In this case, anything in the clipboard is pasted before the script runs. If it would wait for the script to be complete, the correct entities would be pasted. I know this because if I leave the pasteorig out of the code, and wait for the sript to run, and THEN type PASTEORIG, everything is good. Thanks again for your help. Edited September 20, 2011 by el_MI attached code now properly posted Quote
Tharwat Posted September 20, 2011 Posted September 20, 2011 First please read this and use the codes Posting Guidelines . http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines&p=51051&viewfull=1#post51051 Quote
Tharwat Posted September 20, 2011 Posted September 20, 2011 At the moment , here is what I use for vla-activate function and implemented with your drawing file path .. (setq acdoc (vla-get-documents (vlax-get-acad-object))) (vla-activate (vla-open acdoc "C:\\Documents and Settings\\el_MI\\my documents\\auto_lisp\\tests\\[color=red][b]YourDrawingName.dwg[/b][/color]" :vlax-false ) ) Tharwat Quote
el_MI Posted September 20, 2011 Author Posted September 20, 2011 Thank you for that quick response. So what happens now is the drawing specified immediately opens. When I Ctrl/tab back to the original drawing from which the lisp is called, the lisp then runs. Once this is done, I can manually paste to either drawing, as this is till not automated. I tried this both SDI=0 and SDI=1. 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.