Astro Posted December 8, 2009 Share Posted December 8, 2009 Hi all, I need to extract attributes from dynamic blocks to excel. The attout command is good but i need more informations like visibility state and so on... The extraction wizard export all this informations but not the Handle... So what i need is: Export all the attributes +handle id of the blocks +visibility state +Real blockname (with attout command the block names look like *U18, *U72 ....) Maybee somebody has already a lisp routine who do this Hope somebody can help me, it's urgent. Thanks in advance for your support! Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 Could you upload a sample dwg?? Quote Link to comment Share on other sites More sharing options...
Astro Posted December 8, 2009 Author Share Posted December 8, 2009 In attachment the drawing containing 3 dynamic blocks. The attributes of those blocks are different. OLDdrawing2.dwg Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 In attachment the drawing containing 3 dynamic blocks.The attributes of those blocks are different. Astro give me the CSV format for returned data. Feel free to direct contact me. See attached file !!!wheretosend.txt Quote Link to comment Share on other sites More sharing options...
Astro Posted December 8, 2009 Author Share Posted December 8, 2009 Thank you for your help . In attachment the files. The one starting with xls is an excel extracted with the extraction wizard. Just rename it to xls. (Cannot upload xls...) The other one is with -attout command OLDdrawing2.txt XLSOLDdrawing2.txt Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 I did it before your post OLDdrawing2 - Standard.zip Quote Link to comment Share on other sites More sharing options...
Astro Posted December 8, 2009 Author Share Posted December 8, 2009 when i execute the command i have foloowing error Command: _appload GET DATA FROM DYN BLOCK.LSP successfully loaded. Command: prompt DYN-DAT at the command line Command: Command: dyn-dat ; error: no function definition: LIST$2CVS Command: Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ (defun list$2cvs (#lst) (if (not ( listp #lst)) (setq #lst (list #lst)) ) (apply 'strcat (cons (car #lst) (mapcar '(lambda (str) (strcat "," str)) (cdr #lst) ) ;_mapcar ) ;_cons ) ;_apply ) ;_ string-list2cvs ;;;usage(string-list2cvs '("One" "Two" "Three")) ;;;->"One,Two,Three" ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ Quote Link to comment Share on other sites More sharing options...
Danny Posted December 8, 2009 Share Posted December 8, 2009 I did it before your post Very interesting tread, very useful, however never use a word like Standard again This is a fictious idea that has never been realized. Kind of like a 'Go By Job' yet another engineer/proposal idea that does not exsist in real life. Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 Hi Dany , what I mean by I did it before your post Is about the CSV format . As I ask him to show the way it want the csv to be, but I end the lisp before he post both TXT and XLS files. Quote Link to comment Share on other sites More sharing options...
Danny Posted December 8, 2009 Share Posted December 8, 2009 Hi Dany , what I mean by I did it before your post Is about the CSV format . As I ask him to show the way it want the csv to be, but I end the lisp before he post both TXT and XLS files. Just making a Joke Bro. I did understand your thread and thought there was useful information in it Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2009 Share Posted December 8, 2009 Just making a Joke Bro. I did understand your thread and thought there was useful information in it Hi Danny , as English is not my native idiom , I did not understood your message. All clear. Quote Link to comment Share on other sites More sharing options...
Astro Posted December 9, 2009 Author Share Posted December 9, 2009 ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ (defun list$2cvs (#lst) (if (not ( listp #lst)) (setq #lst (list #lst)) ) (apply 'strcat (cons (car #lst) (mapcar '(lambda (str) (strcat "," str)) (cdr #lst) ) ;_mapcar ) ;_cons ) ;_apply ) ;_ string-list2cvs ;;;usage(string-list2cvs '("One" "Two" "Three")) ;;;->"One,Two,Three" ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ I added this to the code but have still an error Command: dyn-dat; error: bad argument type: lselsetp nil Command: Maybe i did something wrong? Quote Link to comment Share on other sites More sharing options...
devitg Posted December 9, 2009 Share Posted December 9, 2009 I added this to the code but have still an error Maybe i did something wrong? Test it , please. ;;************************************************************ ;; Design by Gabo CALOS DE VIT from CORDOBA ARGENTINA ;;; Copyleft 1995-2009 by Gabriel Calos De Vit ;; DEVITG@GMAIL.COM ;;-******************************************************************************************************************************* (DEFUN guarda-lista-csv-w (lista / ar ;;; nombre-archivo ) (SETQ nombre-archivo (STRCAT (GETVAR "dwgprefix") (VL-FILENAME-BASE (GETVAR "dwgname")) ".csv")) (SETQ ar (OPEN nombre-archivo "w")) (FOREACH texto lista (WRITE-LINE texto ar) ) (CLOSE ar) ) ;;-******************************************************************************************************************************* ;;;--------------------------------------------------------------------------------------------------------- ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ ;;;Juerg Menzi ;;;MENZI ENGINEERING GmbH, Switzerland ;;;http://www.menziengineering.ch ; == Function MeGetAtts ; Reads all attribute values from a block ; Arguments [Typ]: ; Obj = Object [VLA-OBJECT] ; Return [Typ]: ; > Dotted pair list '(("Tag1" . "Val1")...) [list] ; Notes: ; None ; (defun MeGetAtts (Obj) (mapcar '(lambda (Att) (cons (vla-get-TagString Att) (vla-get-TextString Att) ) ) (vlax-invoke Obj 'GetAttributes) ) ) ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* ;; TASK TO DO ;;;Export all the attributes ;;;+handle id of the blocks ;;;+visibility state ;;;+Real blockname (defun GET-NAME+HANDLE+VISIBLE+ATTs ( / ACAD* ADOC ALL-INSERTED-CSV-LIST ALL-INSERTED-DATA-LIST ATT-PAIR-LIST CSV-LIST DATA-LIST DATA-LIST< HANDLE nombre-archivo INSERTED-CSV INSERTED-LIST INSERTED-SS NAME VISIBLE ) (vl-load-com) (setq acad* (vlax-get-acad-object)) ;_ ACAD (setq adoc (vla-get-activedocument acad*)) ;_ DWG active (setq insertED-SS (ssget "_X" '(( 0 . "insert"))));_ all inserted blocks (setq inserted-list (mapcar 'vlax-ename->vla-object (vl-remove-if-not '(lambda(x)(= (type x) 'ENAME)) (mapcar 'cadr (ssnamex insertED-SS)))));_ a list of inserted (setq all-inserted-csv-list nil) (setq all-inserted-data-list nil) (foreach inserted inserted-list (setq data-list nil) (setq csv-list nil) (setq name (vla-get-EffectiveName inserted)) (setq data-list (cons (cons "NAME" name) data-list)) (setq handle (vla-get-Handle inserted)) (setq data-list (cons (CONS "HANDLE" handle) data-list)) (setq visible (if (vla-get-Visible inserted) "visible" "no visible" );_ if );_ visible (setq data-list (cons (cons "VISIBLE" visible) data-list)) (setq csv-list (reverse(list name handle visible ) )) (if (vla-get-hasAttributes inserted ) (progn (setq att-pair-list (MeGetAtts inserted)) (foreach att-pair att-pair-list (setq data-list ( cons att-pair data-list)) (setq csv-list (cons (Cdr att-pair) csv-list)) ) );_ progn );If has attribute (setq inserted-csv (list$2cvs (reverse csv-list))) (setq data-list< (reverse data-list)) (setq all-inserted-data-list (cons data-list< all-inserted-data-list)) (setq all-inserted-csv-list (cons inserted-csv all-inserted-csv-list)) );_ foreach inserted (setq blk-qty (length all-inserted-csv-list)) (guarda-lista-csv-w all-inserted-csv-list) (alert (strcat "\n Data form : \n " (Itoa blk-qty) " BLOCKS \n has been sent to .. \n" nombre-archivo )) (princ) );_ defun ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* (defun c:dyn-dat () (GET-NAME+HANDLE+VISIBLE+ATTs) ) ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/* ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ (defun list$2cvs (#lst) (if (not ( listp #lst)) (setq #lst (list #lst)) ) (apply 'strcat (cons (car #lst) (mapcar '(lambda (str) (strcat "," str)) (cdr #lst) ) ;_mapcar ) ;_cons ) ;_apply ) ;_ string-list2cvs ;;;usage(string-list2cvs '("One" "Two" "Three")) ;;;->"One,Two,Three" ;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/ (prompt "prompt DYN-DAT at the command line") ;|«Visual LISP© Format Options» (72 2 1 0 nil "end of " 100 20 2 0 0 nil T nil T) ;*** DO NOT add text below the comment! ***|; Quote Link to comment Share on other sites More sharing options...
Astro Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks it works now I have some remarks, -is it possible to get the outputformat to an xls with tab delimited tabs an titles on the header? -when the handle id is something like 48E8, excel interprets it like 4.80E+09 so --> 4800000000 with -attout command the handle is '48E8 and then excel recognize it -last one is, i need the visibility state of my dynamic block. Not if it's visible or not. So my dynamic block can have up to 20 visibility states e.g. and i need them in the excel. Thanks again for your good work Quote Link to comment Share on other sites More sharing options...
devitg Posted December 9, 2009 Share Posted December 9, 2009 Thanks it works now I have some remarks, -is it possible to get the outputformat to an xls with tab delimited tabs an titles on the header? If you open the csv by excell , no need to be TAB delimited. About header can be so , I will fix. -when the handle id is something like 48E8, excel interprets it like 4.80E+09 so --> 4800000000 If you open the csv by excell, it will show as text, see attached image. with -attout command the handle is '48E8 and then excel recognize it -last one is, i need the visibility state of my dynamic block. Not if it's visible or not. So my dynamic block can have up to 20 visibility states e.g. and i need them in the excel. As i do not do dyn blocks, I do not know what the visibility state covers or mean, and I understood that it is a feature of the block, no the inserted block or blockreference.Please clear it . Thanks again for your good work My comments in blue 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.