Author Topic: Export Layout  (Read 2991 times)

0 Members and 1 Guest are viewing this topic.

Patrick_35

  • Guest
Export Layout
« on: December 22, 2009, 05:48:47 AM »
Hi

I want to export a layout in a file

For example
Code: [Select]
  (defun ouvrir_dessin_dbx(dwg / dbx doc lan rel)
    (and (setq dwg (findfile dwg))
      (progn
(vlax-for doc (vla-get-documents (vlax-get-acad-object))
  (and (eq (strcase (vla-get-fullname doc)) (strcase dwg))
    (setq dbx doc lan T)
  )
)
(and (not dbx)
  (setq dbx (vlax-create-object (if (< (setq rel (atoi (getvar "ACADVER"))) 16)
  "ObjectDBX.AxDbDocument"
  (strcat "ObjectDBX.AxDbDocument." (itoa rel))
)
    )
  )
  (vla-open dbx dwg)
)
      )
    )
    (list dbx lan)
  )

  (setq dbx (ouvrir_dessin_dbx "c:/test/fichier_test.dwg")
cal (vlax-safearray-fill
      (vlax-make-safearray vlax-vbObject (cons 0 0))
      (list (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
    )
cod (vla-get-layouts (car dbx))
  )

I do not understand why a
Code: [Select]
(vla-copyobjects (vla-get-activedocument (vlax-get-acad-object)) cal cod)does not work the first time and if I redo a
Code: [Select]
(vla-copyobjects (vla-get-activedocument (vlax-get-acad-object)) cal cod)it works but the drawing is Recoverable

@+

Fred Tomke

  • Newt
  • Posts: 38
  • [ Mr. Bad Guy ]
Re: Export Layout
« Reply #1 on: December 22, 2009, 06:50:04 AM »
Hi,Patrick_35

I had a try. With your code AutoCAD terminated when opening the drawing in which I copied the layout to.
Then I've changed this:

  • I've changed the lines a bit (but not much).
  • I've made a paperspace active in the current drawing.

After loading the code everything worked as expected. I'm not sure what the real reason was.
In the destroyed drawing the content of the existing layout (of test.dwg) was moved into a new layout and the original layout was empty.
After using the new code in a restartet AutoCAD session it worked perfectly.

Give it a new try with this code and make sure that the active layout of the current drawing is not the modelspace.

Code: [Select]
(defun ouvrir_dessin_dbx(dwg / dbx doc lan rel)
    (and (setq dwg (findfile dwg))
      (progn
(vlax-for doc (vla-get-documents (vlax-get-acad-object))
  (and (eq (strcase (vla-get-fullname doc)) (strcase dwg))
    (setq dbx doc lan T)
  )
)
(and (not dbx)
  (setq dbx (vlax-create-object (if (< (setq rel (atoi (getvar "ACADVER"))) 16)
  "ObjectDBX.AxDbDocument"
  (strcat "ObjectDBX.AxDbDocument." (itoa rel))
)
    )
  )
  (vla-open dbx dwg)
)
      )
    )
    (list dbx lan)
  )

(defun c:test ()
  (setq oDoc (vla-get-activedocument (vlax-get-acad-object))
        dbx (ouvrir_dessin_dbx "d:/test.dwg")
cal (vlax-safearray-fill
      (vlax-make-safearray vlax-vbObject (cons 0 0))
      (list (vla-get-activelayout oDoc))
    )
cod (vla-get-layouts (car dbx))
  )
  (vla-copyobjects oDoc cal cod)
  (vla-saveas (car dbx) "d:/test.dwg")
  (vlax-release-object (car dbx))
); test

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Patrick_35

  • Guest
Re: Export Layout
« Reply #2 on: December 22, 2009, 07:25:33 AM »
Thanks for your reply

The simplest is that I give the entire lisp

I'd like to avoid using the vl-catch-all-error-p
Code: [Select]
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-copyobjects (list doc cal cod)))
  (vla-copyobjects doc cal cod)
)

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Export Layout
« Reply #3 on: December 22, 2009, 08:57:35 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: Export Layout
« Reply #4 on: December 22, 2009, 09:42:50 AM »
Have you tried this one by Tim?
http://www.theswamp.org/index.php?topic=19721.msg240368#msg240368

Thank you very much cab  :-)
I resolve my problem with the lisp of T.Willey

You are kings

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Export Layout
« Reply #5 on: December 22, 2009, 09:54:47 AM »
You're welcome. Tim is a good guy to have around. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.