Jump to content

Help : Export a selection to new drawing and zoom extend


mhy3sx

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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 

  • Like 1
Link to comment
Share on other sites

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