mhy3sx Posted March 11, 2023 Posted March 11, 2023 Hi. I use this code to export a selection to a new empty drawing. The problem is that I can not find a way the new created file to be zoom extend. (defun c:test (/ app docs doc objects ss i n sslist) (setq app (vlax-get-acad-object)) (setq doc (vla-get-activedocument app)) (setq docs (vla-get-documents app)) (setq ss (ssget (list (cons 410 (Getvar"CTAB" ))))) (setq n (sslength ss) i 0) (repeat n (setq sslist (append sslist (list (vlax-ename->vla-object (ssname ss i))))) (setq i (1+ i)) ) (setq objects (vlax-make-safearray vlax-vbObject (cons 0 (1- n)))) (vlax-safearray-fill objects sslist) (setq doc_new (vla-add docs "c:\\mydwt\\Template\\test.dwt")) (vla-copyobjects doc objects (vla-get-modelspace doc_new) ) (princ) ) Thanks Quote
Steven P Posted March 11, 2023 Posted March 11, 2023 You are running the LISP in one document and want to control another document from there, that is quite tricky to do with just a LISP. You might look at making a script to do this, to open the new file, do what you want to do, save and close, but you are going to really struggle doing this just by LISP, loads of examples out there something like a scipt file containing this: _Open c:\\mydwt\\Template\\test.dwt _zoom _extents _close yes and thin in your LISP something like this to run the script: (command "_.script" Scrfile.scr) Remembering that it is the weekend here so this is untested, CAD is off you see. Give you an idea where to go Quote
mhy3sx Posted March 12, 2023 Author Posted March 12, 2023 Hi, Steven P. the file will be already open in a new tab (vla-copyobjects doc objects (vla-get-modelspace doc_new)) That's why I was thinking if it is any way to be zoom extend. Thanks Quote
Steven P Posted March 12, 2023 Posted March 12, 2023 Unfortunately I've not found a satisfactory way to do that with a file that is already open. The main problem with LISP is that it runs in the document that opens it, when you move to another document, that document is not the file running the LISP and so it all stops. Scripts run outside of the drawing, but to change drawing they like to use commands or LISPs. As far as I know there is no command to change focus to a different drawing, but there is a command to open or close a file - which is what I tend to do. If it is a newly created drawing then I'd do the copy part first, then create and open the drawing, paste and zoom, save and close to return to the original. Not sure if this is a function that another language can handle 1 Quote
tombu Posted March 13, 2023 Posted March 13, 2023 Like Steven I'm home now but usually employ a simpler approach at work. My Paste drop-down includes a macro to paste and zoom extents. Quote
BIGAL Posted March 13, 2023 Posted March 13, 2023 A script Wblock selected New dwg or open using your template Insert wblock explode once purge anonymous block Zoom extents Quote
Steven P Posted March 13, 2023 Posted March 13, 2023 Problem I found is the second drawing is open 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.