buntobaggins Posted 22 hours ago Posted 22 hours ago I am currently writing a program that will take layouts defined in a template file and copy them over to the current drawing. But running this program will cause the the file to break. The new layouts will not show up and if you attempt to switch to a different layout AutoCad will crash. If you try to open the file up again AutoCad will say its corrupted and will repair the file which seems to fix the problem. (defun c:copyLayouts () (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (setq impdwg (getfiled "Select Master Template" "" "dwt" 16)) (setq impdoc (vla-getinterfaceobject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." (itoa (atoi (getvar 'acadver)))) );vla-getinterfaceobject );setq (vl-catch-all-apply 'vla-open (list impdoc impdwg)) (setq layoat (vlax-get-property impdoc 'layouts)) (setq safeLayout (vlax-make-safearray vlax-vbObject (cons 0 (- (vla-get-count layoat) 1)))) (setq i 0) (repeat (vla-get-count layoat) (vlax-safearray-put-element safeLayout i (vla-item layoat i)) (setq i (1+ i)) );repeat (vla-CopyObjects impdoc safeLayout (vlax-get-property doc 'layouts)) (princ "\n\ncopy done\n\n") (princ) );defun This only seems to be a problem with layouts. Using the same code for say a UCS works just fine. This is probably just some stupid mistake but I have been stuck on this for a while now so any help would be appreciated. Quote
mhupp Posted 1 hour ago Posted 1 hour ago https://www.lee-mac.com/steal.html (Steal "C:\\My Folder\\MyDrawing.dwg" '(("Layouts" ("Page1" "Page2")))) 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.