minhphuong_humg Posted February 7, 2014 Posted February 7, 2014 Hi all, I have a drawing with Attributes and Dimension. I want get value Attributes and Dimensions to Excel (2010) (view file Now.rar attachment). Please, help me get value Attributes and Dimensions to Excel by autolisp. Thank you very much! File: Now.zip Quote
BIGAL Posted February 7, 2014 Posted February 7, 2014 Before doing anything do a proper search here this has been solved many times. "EXCEl" & "Atrributes" Quote
minhphuong_humg Posted February 7, 2014 Author Posted February 7, 2014 Before doing anything do a proper search here this has been solved many times. "EXCEl" & "Atrributes" Dir, Bigal. I tried searching, but things were not looking for something to help with specific cases like mine. If possible, can you help me in this case? Thank you. Quote
Tharwat Posted February 7, 2014 Posted February 7, 2014 Hi , Did not you solve your problem in this thread with the help of Marko ? http://www.theswamp.org/index.php?topic=46057.msg511617#msg511617 Quote
ReMark Posted February 7, 2014 Posted February 7, 2014 Attributes to Excel. Use DATAEXTRACTION or use this....http://www.cadstudio.cz/excellink Dimensions to Excel. Use this...http://forums.cadalyst.com/showthread.php?t=5965 Quote
minhphuong_humg Posted February 9, 2014 Author Posted February 9, 2014 Hi , Did not you solve your problem in this thread with the help of Marko ? http://www.theswamp.org/index.php?topic=46057.msg511617#msg511617 Dir, Tharwat Thank you quoted, but in case of Ribarm help I have used Attribute Block + Dynamic Block (don't Aligned Dimensions). case of Marko help I have used Circles and Text (two text) [don't Attribute Block] + Dimensions. For now, In my drawing I only use the Attribute Block + Aligned Dimension (not Dynamic Dimension). I hope you understand that. Perhaps, you have not test on my data attached. It differs from in put in all of Marko, Ribarm. We hope you consider specific on the data that I have attached. Hope to receive help. Thank you very much. Quote
minhphuong_humg Posted February 9, 2014 Author Posted February 9, 2014 Attributes to Excel. Use DATAEXTRACTION or use this....http://www.cadstudio.cz/excellink Dimensions to Excel. Use this...http://forums.cadalyst.com/showthread.php?t=5965 I want them combined into an AutoLISP file to solve my problem is not solved by two discrete issues. Thank you. Quote
Tharwat Posted February 9, 2014 Posted February 9, 2014 I have wrote a program yesterday evening at home and I think it is a great tool since that you are allowed to select the dimensions with the Buble attributed block in one shut and you'd have the Excel file in the same location where the current drawing 's location is . So you need to wait till evening till I get home to post the code for you to test Good luck . Quote
ReMark Posted February 9, 2014 Posted February 9, 2014 I want them combined into an AutoLISP file to solve my problem is not solved by two discrete issues.Thank you. Can we see what effort you have made toward solving the problem? Post your code. Quote
minhphuong_humg Posted February 9, 2014 Author Posted February 9, 2014 I have wrote a program yesterday evening at home and I think it is a great tool since that you are allowed to select the dimensions with the Buble attributed block in one shut and you'd have the Excel file in the same location where the current drawing 's location is . So you need to wait till evening till I get home to post the code for you to test Good luck . Thank Tharwat very much! I hope you help me! I will waiting for your help! Good luck for you. Quote
Tharwat Posted February 9, 2014 Posted February 9, 2014 (edited) Try it and let me know by selecting all dimensions and attributed blocks . (defun c:Test (/ ss i sn vl p lst bks s d at l a f o) ;; Author : Tharwat Al Shoufi ;; ;; Date : 08. Feb. 2014 ;; (princ "\n Select Dimensions with Attributed Block < Buble > " ) (if (setq ss (ssget '((-4 . "<OR") (0 . "DIMENSION") (-4 . "<AND") (0 . "INSERT") (2 . "Buble") (-4 . "AND>") (-4 . "OR>") ) ) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i))) vl (vlax-ename->vla-object sn) ) (if (eq (cdr (assoc 0 (entget sn))) "DIMENSION") (progn (if (/= (vla-get-Arrowhead1Block vl) "None" ) (setq p (cdr (assoc 13 (entget sn)))) (setq p (cdr (assoc 14 (entget sn)))) ) (setq lst (cons (list p (rtos (cdr (assoc 42 (entget sn))) 2 0) ) lst ) ) ) (setq bks (cons (list (cdr (assoc 10 (entget sn))) vl) bks)) ) ) ) (foreach x lst (if (and (car x) (car bks)) (progn (setq d (distance (car x) (caar bks)) at (cadr (car bks)) ) (foreach e bks (if (< (setq a (distance (car x) (car e))) d) (setq d a at (cadr e) ) ) ) ) ) (if bks (setq l (cons (append (mapcar '(lambda (u) (list (vla-get-tagstring u) (vla-get-textstring u)) ) (vlax-invoke at 'getattributes) ) (list (cadr x) ) ) l ) ) ) (setq lst (cdr lst)) ) (if l (progn (setq l (vl-sort l '(lambda (j k) (< (atof (cadr (car j))) (atof (cadr (car k))) ) ) ) ) (if (and (setq f (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".csv" ) ) (setq o (open f "w")) ) (progn (setq s (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList" ) ) (",") ) ) (write-line (strcat "NUMBER" s "DIMENSION" s "HEIGHT" s "H1" s "H2" s "H4" s "3F" ) o ) (foreach u l (write-line (strcat (nth 1 (nth 0 u)) s (nth 6 u) s (nth 1 (nth 1 u)) s (nth 1 (nth 2 u)) s (nth 1 (nth 3 u)) s (nth 1 (nth 4 u)) s (nth 1 (nth 5 u)) ) o ) ) (close o) (princ (strcat "\n File path : < " f " > ")) ) (alert "Unable to open or create CSV file for writing !!") ) ) ) (princ) ) (vl-load-com) Edited February 9, 2014 by Tharwat Quote
minhphuong_humg Posted February 9, 2014 Author Posted February 9, 2014 Try it and let me know by selecting all dimensions and attributed blocks . (defun c:Test (/ ss i sn vl p lst bks d at l a f o) ;; Author : Tharwat Al Shoufi ;; ;; Date : 08. Feb. 2014 ;; (princ "\n Select Dimensions with Attributed Block < Buble > " ) (if (setq ss (ssget '((-4 . "<OR") (0 . "DIMENSION") (-4 . "<AND") (0 . "INSERT") (2 . "Buble") (-4 . "AND>") (-4 . "OR>") ) ) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i))) vl (vlax-ename->vla-object sn) ) (if (eq (cdr (assoc 0 (entget sn))) "DIMENSION") (progn (if (/= (vla-get-Arrowhead1Block vl) "None" ) (setq p (cdr (assoc 13 (entget sn)))) (setq p (cdr (assoc 14 (entget sn)))) ) (setq lst (cons (list p (rtos (cdr (assoc 42 (entget sn))) 2 0) ) lst ) ) ) (setq bks (cons (list (cdr (assoc 10 (entget sn))) vl) bks)) ) ) ) (foreach x lst (if (and (car x) (car bks)) (progn (setq d (distance (car x) (caar bks)) at (cadr (car bks)) ) (foreach e bks (if (< (setq a (distance (car x) (car e))) d) (setq d a at (cadr e) ) ) ) ) ) (if bks (setq l (cons (append (mapcar '(lambda (u) (list (vla-get-tagstring u) (vla-get-textstring u)) ) (vlax-invoke at 'getattributes) ) (list (cadr x) ) ) l ) ) ) (setq lst (cdr lst)) ) (if l (progn (setq l (vl-sort l '(lambda (j k) (< (atof (cadr (car j))) (atof (cadr (car k))) ) ) ) ) (if (and (setq f (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".csv" ) ) (setq o (open f "w")) ) (progn (write-line "NUMBER;DIMENSION;HEIGHT;H1;H2;H4;3F" o) (foreach u l (write-line (strcat (nth 1 (nth 0 u)) ";" (nth 6 u) ";" (nth 1 (nth 1 u)) ";" (nth 1 (nth 2 u)) ";" (nth 1 (nth 3 u)) ";" (nth 1 (nth 4 u)) ";" (nth 1 (nth 5 u)) ) o ) ) (close o) (princ (strcat "\n File path : < " f " > ")) ) (alert "Unable to open or create CSV file for writing !!") ) ) ) (princ) ) (vl-load-com) Thank Tharwat very much. I have a few opinion -File out put (*.csv) still group into a column without split other column (B, C, D....). -In column (D (H1)| E (H2)| F (H4)| G (3F)) value in the column is number (1, 2, 3.....) don't (H1, H2, H3, 3F...). The value of the column is taken get in front of number of H1, H2, H4, 3F (ex: H1 = 1H1--->get value 1; 2H1--->get value 2; H4=1H4--->get value 1; 3-3F-->get value 3; 3F--->get value 1;.....) Please, Tharwat help me edit your lisp. Thank you very much. Quote
Tharwat Posted February 9, 2014 Posted February 9, 2014 Although that the first code worked in my system but try the modified codes above and let me know . CODES UPDATED ABOVE Quote
minhphuong_humg Posted February 9, 2014 Author Posted February 9, 2014 Although that the first code worked in my system but try the modified codes above and let me know . CODES UPDATED ABOVE Thank Tharwat very much. I have a few opinion: 1-File output result splitted to other column. However, value in column Ạ is missing number 0 if value is 2.10 =2.1, 16.10-->16.1, 125.10--->125.1. Summary is missing number 0 after the comma. 2-In column (D (H1)| E (H2)| F (H4)| G (3F)) value in the column is number (1, 2, 3.....) don't get value (H1, H2, H3, 3F...). The value of the column is taken get in front of number of H1, H2, H4, 3F (ex: H1 = 1H1--->get value 1; 2H1--->get value 2; H4= get value 1; 3-3F-->get value 3; 3F--->get value 1;.....) P/S: Case 2 (ex: cell A1 (in Excel) = H1) the same function: if(A1="H1",1,left(A1,1) in Excel. I don't know how AutoLISP performances. Please, Tharwat help me! Thank Tharwat very much. Quote
Tharwat Posted February 10, 2014 Posted February 10, 2014 Everything goes very well here , you may need to try it on another machine or we may wait for any of the users here to try it and let us know . Quote
Tharwat Posted February 10, 2014 Posted February 10, 2014 Hope someone would try the code and let us know the outcome of the excel file (if values in ONE or SEPARATE columns ) . Quote
minhphuong_humg Posted February 10, 2014 Author Posted February 10, 2014 Everything goes very well here , you may need to try it on another machine or we may wait for any of the users here to try it and let us know . Dir, Tharwat. I think Tharwat don't understand my opinion . Please, view picture to difference 2 result. Please, help me. Thank Tharwat very much. Quote
Tharwat Posted February 10, 2014 Posted February 10, 2014 I think Tharwat don't understand my opinion . I will consider this phrase as the English language is not your native one , so I would ignore it . Back to theme , Select the whole column A by pressing on the first cell in Excel then right click -> general -> number then increase the decimal numbers as much as you want . Quote
minhphuong_humg Posted February 10, 2014 Author Posted February 10, 2014 I will consider this phrase as the English language is not your native one , so I would ignore it . Back to theme , Select the whole column A by pressing on the first cell in Excel then right click -> general -> number then increase the decimal numbers as much as you want . Yes, . I'm Vietnamese. I understan the language is hurdle of us. Please, help me Case 2 is get value in column H1, H2, H4, 3-3F. Thank you very much! So You please view image. Thank you very much. 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.