Jonathan1218 Posted November 6, 2020 Posted November 6, 2020 Hey guys, I can't seem to find a forum with this request, but if there is I apologize. I want to export the DWG name along with layouts from a Sheet Set Manager or single directory to an Excel Spreadsheet. This applies to multiple .dwg files within a directory. Quote
Steven P Posted November 6, 2020 Posted November 6, 2020 You should be able to make this is up (strcat (getvar "dwgprefix")(getvar "dwgname")) Will give you File path (dwgprefix) and drawing name (dwgname) (layoutlist) Will give you the list of layouts. There are a lot of examples on here to export text to excel . Depending on your LISP experience depends how much help you might want putting it all together, but.... it's gone home time for me, time to stretch the legs but hopefully this will give you a clue to get started Oh, if you can't get the excel thing to work.. export to a text file saved as CSV and excel will open then as well Then when you have it all working for one file, there are script editors out there or you could put it all together in the core console to do it for a directory - but get it working for 1 file first Quote
Jonathan Handojo Posted November 7, 2020 Posted November 7, 2020 (edited) I'm no expert when it comes to this, but this should get you started: (defun c:test ( / *error* acadobj csv det dwgdoc dwgs getdoc lays opf sep) (setq dwgs ; Here's your list of dwg files. Use full file path. '( "C:\\Users\\jhandojo\\Desktop\\File1.dwg" "C:\\Users\\jhandojo\\Desktop\\File2.dwg" "C:\\Users\\jhandojo\\Desktop\\File3.dwg" ) ) (defun *error* (msg) (if dwgdoc (vl-catch-all-apply 'vlax-release-object (list dwgdoc))) (if opf (close opf)) (if (not (wcmatch (strcase msg t) "*break*,*cancel*,*exit*")) (princ (strcat "\nError: " msg))) ) (defun getdoc (obj nm / dcs dwgdoc) (vlax-map-collection (vla-get-documents obj) '(lambda (x) (setq dcs (cons (cons (strcase (vla-get-fullname x)) x) dcs)) ) ) (cond ((cdr (assoc (strcase nm) dcs))) ((progn (setq dwgdoc (vla-GetInterfaceObject obj (strcat "ObjectDBX.AxDbDocument." (itoa (atoi (getvar 'acadver)))))) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list dwgdoc nm :vlax-true)))) ) dwgdoc ) ) ) (setq acadobj (vlax-get-acad-object) sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (",")) ) (foreach x dwgs (if (setq dwgdoc (getdoc acadobj x)) (progn (vlax-for y (vla-get-Layouts dwgdoc) (setq lays (cons (cons (vla-get-Name y) (vla-get-taborder y)) lays)) ) (vl-catch-all-apply 'vlax-release-object (list dwgdoc)) ;(setq csv (cons (JH:lst->str (cons x (reverse (mapcar 'car (vl-sort lays '(lambda (a b) (> (cdr a) (cdr b))))))) sep) csv) lays nil) ; If you want to return the full filepath, uncomment this and comment below (setq det (cons (JH:lst->str (cons (vl-filename-base x) (reverse (mapcar 'car (vl-sort lays '(lambda (a b) (> (cdr a) (cdr b))))))) sep) det) lays nil) ) ) ) (if (and (setq csv (getfiled "Select output file" "" "csv" 1)) (setq opf (open csv "w")) ) (progn (foreach x (cons (JH:lst->str '("Drawing Name" "Layouts") sep) (reverse det)) (write-line x opf) ) (close opf) (alert "\nCSV file successfully created") ) ) (princ) ) ;; JH:lst->str --> Jonathan Handojo ;; Concatenates a list of string into one string with a specified delimeter ;; lst - list of strings ;; del - delimiter string (defun JH:lst->str (lst del) (apply 'strcat (append (list (car lst)) (mapcar '(lambda (x) (strcat del x)) (cdr lst)))) ) Edited November 7, 2020 by Jonathan Handojo 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.