Freerefill Posted August 26, 2009 Posted August 26, 2009 Is there a way to produce a list of layout tabs from a .dwg that you do not have open? My initial idea was to create a new AutoCAD object and link a file, much like one would do when working with an Excel file.. however, doing so opened up a new instance of AutoCAD, which I'd rather avoid. The ability must be there, because ADCENTER will let you drag stuff in, including layout tabs. Is there a way to do this via LISP? Any suggestions will be helpful. ^^ Quote
Lee Mac Posted August 26, 2009 Posted August 26, 2009 Perhaps using ObjectDBX to access the unopened drawing? Might be an option to consider. Quote
Lee Mac Posted August 26, 2009 Posted August 26, 2009 As an example: ;; ObjectDBX Example, by Lee McDonnell (defun ODBX (fname / doc dbx lst flag) (vl-load-com) (vlax-for doc (vla-get-Documents (vlax-get-acad-object)) (and (eq (strcase (vla-get-fullname doc)) (strcase fname)) (setq dbx doc))) (and (not dbx) (setq flag t) (setq dbx (vlax-create-object (if (< (setq acVer (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acVer)))))) (cond ((and flag (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list dbx fname)))) (princ (strcat "\n** Error Opening: " (vl-filename-base fname) " **"))) (t (vlax-for lay (vla-get-Layouts dbx) (setq lst (cons (vla-get-name lay) lst))))) (ObjRel (list dbx)) (gc) (gc) lst) ;; Release Objects ~ Requires List of Variables (defun ObjRel (lst) (mapcar (function (lambda (x) (if (and (eq (type x) 'VLA-OBJECT) (not (vlax-object-released-p x))) (vl-catch-all-apply 'vlax-release-object (list x))))) lst)) (defun c:test ( ) (odbx (getfiled "select" "" "dwg" 16))) Quote
Freerefill Posted August 26, 2009 Author Posted August 26, 2009 Very nice, thank you, Lee ^.^ Took me a few tries to understand what was going on, but I think I've got it. I'll have to look further into ObjectDBX to get a more complete understanding. Again, thank you. ^^ Quote
JohnM Posted August 26, 2009 Posted August 26, 2009 i dont know how to link to another post so i borowwed this from another post from patric_35. this will get you going in the right direction (defun c:lstdwg(/ dirbox Ouvrir_dessin_dbx rep lst fic dbx lay) (defun dirbox(/ cdl rep) (if (setq cdl (vlax-create-object "Shell.Application")) (progn (and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Choose a directory" 512 "")) (setq rep (vlax-get-property (vlax-get-property rep 'self) 'path)) ) (vlax-release-object cdl) ) ) rep ) (defun Ouvrir_dessin_dbx(dwg / dbx doc lan) (vl-load-com) (setq dwg (findfile dwg)) (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (and (eq (strcase (vla-get-fullname doc)) (strcase dwg)) (setq dbx doc lan T) ) ) (or dbx (progn (if (< (atoi (substr (getvar "ACADVER") 1 2)) 16) (setq dbx (vlax-create-object "ObjectDBX.AxDbDocument")) (setq dbx (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2)))) ) (vla-open dbx dwg) ) ) (list dbx lan) ) (vl-load-com) (if (setq rep (dirbox)) (if (setq lst (vl-directory-files rep "*.dwg" 1)) (foreach fic lst (if (setq dbx (ouvrir_dessin_dbx (strcat rep "/" fic))) (progn (princ (strcat "\n Working in " fic))(princ) (vlax-for lay (vla-get-layouts (car dbx)) (princ (strcat "\n\t\tLayout : " (vla-get-name lay)))(princ) ) (or (cadr dbx)(vlax-release-object (car dbx))) ) (princ (strcat "\n Can't read file " fic)) ) ) (alert "No dwg's File") ) ) (princ) ) Quote
Freerefill Posted August 26, 2009 Author Posted August 26, 2009 Thanks JohnM. I'll take a good look at that one too. ^.^ Quote
Commandobill Posted August 27, 2009 Posted August 27, 2009 As an addendum to this question. Is there a vla way to copy a layout? I dont want the command line cop out way. I know how to do that. Any help would be appreciated. Quote
Lee Mac Posted August 27, 2009 Posted August 27, 2009 I thought maybe CopyFrom method, but this is only settings I think Quote
JohnM Posted August 27, 2009 Posted August 27, 2009 i would look at vla-add to creat a new layout tab then use ssget to get the old objects and copy to put them in the new tab Quote
Commandobill Posted August 27, 2009 Posted August 27, 2009 I thought maybe CopyFrom method, but this is only settings I think thats all you got? lol thanks Quote
Lee Mac Posted August 27, 2009 Posted August 27, 2009 thats all you got? lol thanks 'fraid so, drawing a blank on this one - apart from the obvious to copy it all manually... 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.