au-s Posted May 8, 2009 Posted May 8, 2009 thanx... one more thing... When I use it on another dwg file it over-writes exsisting *csv. Can it be done so it checks that its extracting from another *.dwg file and if so the case it adds rows below in attributes.csv?? So it always checks which file it is and if it matches the file dwg name it over-writes the rows corresponding to the dwg-name... Sorry for beeing annoying Thanx in advance. Regards! Quote
Lee Mac Posted May 8, 2009 Posted May 8, 2009 A quick fix - I may consider re-writing this ; Global ATTribute EXtractor ; by Miklos Fuccaro mfuccaro@hotmail.com ;-------------------------November 2004 ------- ;;Edited March 2006 by C. Bassler to allow specification of block and tage names to extract (defun gattex () (setq Blocklist '("Name1" "Name2" "Name3")) ;; ** edit to include block names to select (setq TagList '("Tag1" "TAG2" "Tag3")) ;; ** edit to include tag names to extract ;;create block names separated by columns, for selection filter (setq Blocknames (List2String BlockList)) (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlockNames)))) (if (not ss) (quit)) (setq Root (getvar "DWGPREFIX")) (setq file (open (strcat Root (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME") 4))) "attributes.CSV") "w") i -1) (write-line (strcat Root (getvar "DWGNAME") " -found " (itoa (sslength ss)) " block(s) with attributes") file) (repeat (sslength ss) (setq TagRow nil ValRow nil) (setq Edata (entget (setq e (ssname ss (setq i (1+ i)))))) (write-line "" file) (write-line (strcat "block name:" "," (Dxf 2 Edata)) file) (while (/= (Dxf 0 Edata) "SEQEND") (if (and (= (Dxf 0 Edata) "ATTRIB") (member (dxf 2 Edata) TagList) ;;if tag is on list ) ;and (progn (setq TagRow (cons (Dxf 2 Edata) TagRow)) (setq valRow (cons (Dxf 1 Edata) ValRow)) ) ;progn ) (setq Edata (entget (setq e (entnext e)))) ) ;while (write-line (List2String (reverse TagRow)) file) (write-line (List2String (reverse ValRow)) file) ) ;repeat (close file) (princ (strcat "\nDone writing file " Root "attributes.csv")) (princ) ) ;defun ;;------------------------------- (defun List2String (Alist) (setq NumStr (length Alist)) (foreach Item AList (if (= Item (car AList)) ;;first item (setq LongString (car AList)) (setq LongString (strcat LongString "," Item)) ) ) LongString ) ;defun ;;-------------------------------- (defun Dxf (code pairs) (cdr (assoc code pairs)) ) (gattex) Quote
ronjonp Posted May 9, 2009 Posted May 9, 2009 Remove the last element? (list (car pt)(cadr pt)) Quote
MarcoW Posted May 9, 2009 Posted May 9, 2009 Am I getting this correctly? This routine will extract all attribute info to a csv file? Question, how to modify the lisp so it wil only extract the attribute values of a specific block, i.e. "title". I thought (i think too much sometimes): when havin 10 layouts (drawings) with 10 "title" blocks in the right corner below of each layout, the lisp will extract exactly the info that i need to create a drawing list. So i figured, making the list in excel and copy only the info i need to the right cells. It would be great having a way to creat such drawing list for the automation wil save a lot of time and it is a great way to check the date's of the specific drawings. Even better it would be when having a file that contains the specific data wich is used by autocad when opening a drawing. So "in reverse". Ie. when creating a drawing with date in the title block, then give a command like "update drawing list". There will be created a file called drawing list (in the same folder as the drawing itself). WHenever either one of the files is updated the info must be exchanged... Anyone got a thingy that does it? I will not ask for you to write it for me... Or would you ? Quote
Lee Mac Posted May 9, 2009 Posted May 9, 2009 How can I convert 3d point to 2d point Waqashraf - You have already posted this question in another unrelated thread and it has been answered in much the same way. I will ask you again - if you have a new question, create a new thread. It will get your question answered both quicker and more accurately, and will also help with user searches. Please don't double post. Lee Quote
Lee Mac Posted May 9, 2009 Posted May 9, 2009 Am I getting this correctly? This routine will extract all attribute info to a csv file? Question, how to modify the lisp so it wil only extract the attribute values of a specific block, i.e. "title". I thought (i think too much sometimes): when havin 10 layouts (drawings) with 10 "title" blocks in the right corner below of each layout, the lisp will extract exactly the info that i need to create a drawing list. So i figured, making the list in excel and copy only the info i need to the right cells. It would be great having a way to creat such drawing list for the automation wil save a lot of time and it is a great way to check the date's of the specific drawings. Even better it would be when having a file that contains the specific data wich is used by autocad when opening a drawing. So "in reverse". Ie. when creating a drawing with date in the title block, then give a command like "update drawing list". There will be created a file called drawing list (in the same folder as the drawing itself). WHenever either one of the files is updated the info must be exchanged... Anyone got a thingy that does it? I will not ask for you to write it for me... Or would you ? Firstly, to alter the blocks and attributes that are extracted, just alter the two lists at the very top of the LISP file to whatever block names and attribute tags need reading. As for the drawing list "auto-update", short of using a reactor, I think you would have to run the LISP after all the updates are made to the blocks, and overwrite the existing file with the new values. As for going the other way, i.e. updating the CSV and making it update the title blocks... this could be a bit harder. Quote
MarcoW Posted May 9, 2009 Posted May 9, 2009 Hi Lee, tnx for the reply. I see what you mean, should have seen it before asking you... This lisp is made with sub-functions if i'm right. How do you make it run? I put (defun c:test () before the code and a ) to the very end but it won't run. --> ; error: bad argument type: stringp 4 When speaking about the csv file... would it be easyer when using a database file or so ? ie. Acces...? Quote
Lee Mac Posted May 9, 2009 Posted May 9, 2009 Sorry dude, it had one bracket missing ; Global ATTribute EXtractor ; by Miklos Fuccaro mfuccaro@hotmail.com ;-------------------------November 2004 ------- ;;Edited March 2006 by C. Bassler to allow specification of block and tage names to extract (defun gattex () (setq Blocklist '("Test Blockatt")) ;; ** edit to include block names to select (setq TagList '("TAG1")) ;; ** edit to include tag names to extract ;;create block names separated by columns, for selection filter (setq Blocknames (List2String BlockList)) (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BlockNames)))) (if (not ss) (quit)) (setq Root (getvar "DWGPREFIX")) (setq file (open (strcat Root (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) "attributes.CSV") "w") i -1) (write-line (strcat Root (getvar "DWGNAME") " -found " (itoa (sslength ss)) " block(s) with attributes") file) (repeat (sslength ss) (setq TagRow nil ValRow nil) (setq Edata (entget (setq e (ssname ss (setq i (1+ i)))))) (write-line "" file) (write-line (strcat "block name:" "," (Dxf 2 Edata)) file) (while (/= (Dxf 0 Edata) "SEQEND") (if (and (= (Dxf 0 Edata) "ATTRIB") (member (dxf 2 Edata) TagList) ;;if tag is on list ) ;and (progn (setq TagRow (cons (Dxf 2 Edata) TagRow)) (setq valRow (cons (Dxf 1 Edata) ValRow)) ) ;progn ) (setq Edata (entget (setq e (entnext e)))) ) ;while (write-line (List2String (reverse TagRow)) file) (write-line (List2String (reverse ValRow)) file) ) ;repeat (close file) (princ (strcat "\nDone writing file " Root "attributes.csv")) (princ) ) ;defun ;;------------------------------- (defun List2String (Alist) (setq NumStr (length Alist)) (foreach Item AList (if (= Item (car AList)) ;;first item (setq LongString (car AList)) (setq LongString (strcat LongString "," Item)) ) ) LongString ) ;defun ;;-------------------------------- (defun Dxf (code pairs) (cdr (assoc code pairs)) ) (defun c:test () (gattex) (princ)) type "test" to run I'm not sure you can write to such files as Access etc, without some seriou coding. .txt and .csv are easiest Quote
MarcoW Posted May 9, 2009 Posted May 9, 2009 Still there is an error: Command: test ; error: quit / exit abort I got the right block name ... Quote
Lee Mac Posted May 9, 2009 Posted May 9, 2009 the only way I can reproduce that is to submit the wrong block name - not sure what else it could be Quote
au-s Posted May 11, 2009 Posted May 11, 2009 Nice JOb sir... One problem though... In the previous version I could have a relative path to save file.. like this: (setq file (open (strcat Root "..\\Attribute\\Export\\Litt\\Rooms.CSV") "w") If I do this in your version, the lisp fails: (setq Root (getvar "DWGPREFIX")) (setq file (open (strcat Root (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) "..\\Attribute\\Export\\Litt\\Rooms.CSV") "w") i -1) Thanx in advance for help Sir! Itried also to change path like this... (setq Root (getvar "DWGPREFIX")) [color=red](setq path (strcat "..\\Attribute\\Export\\Litt\\"))[/color] (setq file (open (strcat Root (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) [color=red]path[/color] "Rooms.CSV") "w") i -1) Quote
au-s Posted May 11, 2009 Posted May 11, 2009 I solved it with this one ... My fault.. (setq path (strcat "..\\Attribut\\Export\\Litt\\")) (setq file (open (strcat Root path (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) "Rooms.CSV" ) "w") i -1) Quote
Lee Mac Posted May 11, 2009 Posted May 11, 2009 All I do is save it to the same path as the drawing and strip the extension from the drawing name, (replacing it with csv.). Quote
costadina Posted May 11, 2009 Posted May 11, 2009 Have you guys considered using the built-in ACAD command "Dataextraction". Just enter it in the command line and a Wizard pops up that is basically an elaborate filter. It takes some time to go through, but I've used it successfully several times. You can export the filtered data into several formats (xls, cvs, mdb). Quote
au-s Posted May 12, 2009 Posted May 12, 2009 If I change the row: (setq LongString (strcat LongString "\n" Item)) I changed the "," to "\n" so I can have one item/row. Why is it that the formatting in csv is : I have Tag-1 as 001, 002, 003 etc ... in csv it prints as: 1 2 3 and they are right adjusted in the cell.. The text is okej but the only thing that happens is that it cut the zeros and right adjust numbers. Quote
Britman Posted June 21, 2012 Posted June 21, 2012 Hi Daniel, I am also an instrument guy. Did you ever mod the programme to be able to use it for instrumentation take-offs? Thanks, Chris. Quote
Dadgad Posted June 21, 2012 Posted June 21, 2012 Hi Daniel, I am also an instrument guy. Did you ever mod the programme to be able to use it for instrumentation take-offs? Thanks, Chris. Welcome to the forum Britman. Might this help you? http://www.lee-mac.com/macatt.html If not, there may well be something else on Lee's site which would help you out. Thanks Lee! Your profile shows you using LT, is that correct? If so then I believe lisp won't help you. Do you have DATA EXTRACTION in 2005? Daniel is still a regular on the site, and may well see this and get back to you. Quote
Britman Posted June 21, 2012 Posted June 21, 2012 Thank you so much DADGAD. That programme is awesome!!!! Lee Mac certainly is an incredible guy. You mention me having AutoCad LT 2005, well just at the moment I have access to AutoCad 2009 so I can run .lsp's. Interested in your handle, are you a guitar player? Chris. 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.