Manuel_Kunde Posted October 20, 2021 Share Posted October 20, 2021 (edited) Hi all, I'm looking for a lisp that will write the custom content from the block attributes of a specific block (in this case named "Test_Block") in a CSV File. In the image below, you can see in red the fields that are the same every time, and in green, the variable values I want to select from the block. Does anyone have a template or idea how this should work? Edited October 20, 2021 by Manuel_Kunde Quote Link to comment Share on other sites More sharing options...
mhupp Posted October 20, 2021 Share Posted October 20, 2021 This has most of the function you need. https://github.com/cadavre/MTZ-BA-11_lisp/blob/master/sz/LSP/getexcel.lsp Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted October 20, 2021 Share Posted October 20, 2021 5 hours ago, Manuel_Kunde said: Hi all, I'm looking for a lisp that will write the custom content from the block attributes of a specific block (in this case named "Test_Block") in a CSV File. In the image below, you can see in red the fields that are the same every time, and in green, the variable values I want to select from the block. Does anyone have a template or idea how this should work? Hi Please Attached Drawing example And Excel file 1 Quote Link to comment Share on other sites More sharing options...
Manuel_Kunde Posted October 21, 2021 Author Share Posted October 21, 2021 23 hours ago, hosneyalaa said: Hi Please Attached Drawing example And Excel file Hi, DWG test_door_block.dwg and CSV attached. In the CSV file I have filled the cells in red, which must always be written, and in green the variable numbers, which should be selected from the block. Do you have any idea how this could be done? Thanks in advance. test_door_block.csv Quote Link to comment Share on other sites More sharing options...
dan20047 Posted October 21, 2021 Share Posted October 21, 2021 Have you tried the Express Tools ATTOUT command? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2021 Share Posted October 22, 2021 They are dynamic blocks in your sample so this matches your sample, it can be changed to work with any dynamic blocks. Try it https://www.cadtutor.net/forum/topic/73872-fill-csv-file-with-block-attributes/ ;; Get Dynamic Block Property Value - Lee Mac ;; Returns the value of a Dynamic Block property (if present) ;; blk - [vla] VLA Dynamic Block Reference object ;; prp - [str] Dynamic Block property name (case-insensitive) (defun LM:getdynpropvalue ( blk prp ) (setq prp (strcase prp)) (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) (defun LM:getdynprops ( blk ) (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value))) (vlax-invoke blk 'getdynamicblockproperties) ) ) (defun c:exdynblk ( / ss blk x lst fo str) (setq ss (ssget (list (cons 0 "INSERT")))) (if (= ss nil) (progn (alert "You have not picked blocks ")(exit)) (progn (setq fo (open "d:\\acadtemp\\dynblks.csv" "W")) (setq num 0) (repeat (setq x (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq lst (LM:getdynprops blk )) (setq str (strcat (rtos (setq num (1+ num)) 2 0) "," (rtos(cdr (nth 0 lst)) 2 2) "," (rtos (cdr (nth 2 lst)) 2 2) "," (rtos (cdr (nth 4 lst)) 2 2) ) ) (princ str) (write-line str fo) ) (close fo) ) ) (princ) ) (c:exdynblk) 1 Quote Link to comment Share on other sites More sharing options...
Manuel_Kunde Posted October 22, 2021 Author Share Posted October 22, 2021 2 hours ago, BIGAL said: They are dynamic blocks in your sample so this matches your sample, it can be changed to work with any dynamic blocks. The lisp works very well! The attributes are all written in one line. How can I tell that an attribute goes in a specific row (e.g. cell B2)? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 22, 2021 Share Posted October 22, 2021 Just open the csv with Excel it will auto column, if you use the semi-colon for seperator change the "," to ";" different parts of the world use , v's ; inside Excel. Quote Link to comment Share on other sites More sharing options...
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.