TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Patrick_35 on December 22, 2009, 05:48:47 AM
-
Hi
I want to export a layout in a file
For example
(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
(vla-copyobjects (vla-get-activedocument (vlax-get-acad-object)) cal cod)
does not work the first time and if I redo a
(vla-copyobjects (vla-get-activedocument (vlax-get-acad-object)) cal cod)
it works but the drawing is Recoverable
@+
-
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.
(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
-
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
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-copyobjects (list doc cal cod)))
(vla-copyobjects doc cal cod)
)
@+
-
Have you tried this one by Tim?
http://www.theswamp.org/index.php?topic=19721.msg240368#msg240368
-
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
@+
-
You're welcome. Tim is a good guy to have around. 8-)