buntobaggins Posted Wednesday at 10:10 PM Posted Wednesday at 10:10 PM 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 yesterday at 07:27 PM Posted yesterday at 07:27 PM https://www.lee-mac.com/steal.html (Steal "C:\\My Folder\\MyDrawing.dwg" '(("Layouts" ("Page1" "Page2")))) 1 Quote
buntobaggins Posted yesterday at 08:54 PM Author Posted yesterday at 08:54 PM I am aware of the Steal program but for this project I would like to write my own implementation. Quote
BIGAL Posted 22 hours ago Posted 22 hours ago Why not just use "Layout T" Template it asks for the dwg and which layout i have always used it and no problems. Can run as a (command 1 Quote
SLW210 Posted 10 hours ago Posted 10 hours ago What are you trying to accomplish with this code? First and foremost vla-CopyObjects doesn't support Layouts in the manner you are attempting, AFAIK. You need to use -LAYOUT command or pretty much need to use LeeMac's Steal or at least determine the method he uses for Layouts, which if I am looking at it correctly uses the Block Table record maybe more as I quickly glanced at it. 1 Quote
ronjonp Posted 1 hour ago Posted 1 hour ago You can also use Design Center ( DC ) to copy layouts amongst other things between drawings. 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.