Jump to content

dynamic block with attributes extraction to excel


Astro

Recommended Posts

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!

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

 

(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"

;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

Link to comment
Share on other sites

I did it before your post

 

 

Very interesting tread, very useful, however never use a word like Standard again :D 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

;;*//*/*/*/*/*/*/*/*/*/*/*/*/**/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

 

(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 :oops:

 

Command: dyn-dat

; error: bad argument type: lselsetp nil

Command:

 

Maybe i did something wrong?

Link to comment
Share on other sites

I added this to the code but have still an error :oops:

 

 

 

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! ***|;

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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 :D

 

My comments in blue

hexadecimal numbers has text.gif

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...