nguyenkhanhlucky Posted November 8, 2013 Posted November 8, 2013 Seeking help, write lisp as attachments, select the data fields in autocad length, width, area, perimeter switch to Excelcad to excel 2.pdf file excel Ex.xls file autocad to excel Ex.dwg Quote
MSasu Posted November 8, 2013 Posted November 8, 2013 Did you checked the built-in DATAEXTRACTION command? Quote
nguyenkhanhlucky Posted November 11, 2013 Author Posted November 11, 2013 Hi Msasu I try DATAEXTRACTION and the results are not like expected, if you can do the same this attachments? and sympathy if you do not understand what I write, because I'm not good at english Regards, khanhnguyen Quote
fixo Posted November 11, 2013 Posted November 11, 2013 This will get you started, select your shapes one by another, then do your rest job: (defun c:exwr (/ ar del elist en ent filename fn hgt i maxp minp obj per pmax pmin rowdata wid xldata ) (setq i 0 ) (setq xldata (cons (list "" "Length (mm)" "Width (mm)""Perimeter" "Area")xldata)) (while (setq ent (entsel "\nSelect a rectangle one by another, press Enter to stop loop: ")) (if (and (setq elist (entget (setq en (car ent)))) (eq (cdr (assoc 0 elist)) "LWPOLYLINE") (= (cdr (assoc 70 elist)) 1) (and (> (cdr (assoc 90 elist)) 5) (< (cdr (assoc 90 elist)) 13) ) ) (progn (setq obj (vlax-ename->vla-object en)) (vla-getboundingbox obj 'minp 'maxp) (setq pmin (vlax-safearray->list minp) pmax (vlax-safearray->list maxp)) (setq wid (abs (- (car pmax) (car pmin))) hgt (abs (- (cadr pmax) (cadr pmin))) per (vla-get-length obj) ar (vla-get-area obj) ) (setq rowdata (list (itoa (setq i (1+ i))) (rtos wid 2 2) (rtos hgt 2 2) (rtos per 2 2) (rtos ar 2 2))) ;; gather data in a list (setq xldata (append xldata (list rowdata))) ) (prompt "\nNothing or not closed pline selected.") ) ) (if (> (length xldata) 1) (progn ;; put delimiter to suit: (setq del "\t") ;; build your text file path here: (setq filename (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "_Dim.txt")) (setq fn (open filename "w")) ;; Write info to a file (mapcar '(lambda (x) (write-line (apply 'strcat (append (list (car x)) (mapcar '(lambda (y) (strcat del y)) (cdr x) ) ) ) fn ) ) xldata ) (close fn) (gc) ;; just to see a result (startapp "notepad" filename) ) ) (alert "Open text file with Excel,\nthen save as .xls or .xlsx file") (princ) ) (princ "\n\t***\tStart command with EXWR \t***") (princ) (or (vl-load-com)(princ)) Quote
nguyenkhanhlucky Posted November 12, 2013 Author Posted November 12, 2013 Dear Fixo Thank you, but I never knew about the lisp, it's very hard for me, I do not know how and where to start, I have coppy paste the above code into notepad and save the file. LSP, when not use, you can guide me?, or the unfinished lisp you can complete to help me? thank you very much. Regards, khanhnguyen Quote
MSasu Posted November 12, 2013 Posted November 12, 2013 You may want to check this tutorial on AutoLISP usage writen by Lee Mac. Quote
fixo Posted November 13, 2013 Posted November 13, 2013 Dear Fixo Thank you, but I never knew about the lisp, it's very hard for me, I do not know how and where to start, I have coppy paste the above code into notepad and save the file. LSP, when not use, you can guide me?, or the unfinished lisp you can complete to help me? thank you very much. Regards, khanhnguyen I think you had a problem with copy code, try attached lisp instead: ExWr.LSP 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.