au-s Posted November 4, 2009 Posted November 4, 2009 Hello, I have a lisp from mr miclos, (thanx) which extracts attribute values into a file. I tried without any success to add another column in a csv file. When I do an export from a file with the same block I get this result: [font=Arial][size=2]block name:,_Dorrlitt[/size][/font] [font=Arial][size=2]LITTERA[/size][/font] [font=Arial][size=2]D10H[/size][/font] If I have two or 30 D10H in one file I get : [font=Arial][size=2]block name:,_Dorrlitt[/size][/font] [font=Arial][size=2]LITTERA[/size][/font] [font=Arial][size=2]D10H[/size][/font] 30 times after eachother which means over 90 raws. Add to that another blocks ... the file is beginning to be a long one. What I want is the lisp to add a amount of the same attribute. Maybe like so: [font=Arial][size=2]block name:,_Dorrlitt[/size][/font][font=Arial][size=2]LITTERA[/size][/font][font=Arial][size=2]D10H [/size][/font] [font=Arial][size=2][color=red]30 < amount[/color][/size][/font] Any help on that? Best regards The lisp file looks like this: ; Global ATTribute EXtractor ; by Miklos Fuccaro [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email] ;-------------------------November 2004 ------- ;;Edited March 2006 by C. Bassler to allow specification of block and tage names to extract (defun gattexdorr () (setq Blocklist '("_Dorrlitt")) ;; ** edit to include block names to select (setq TagList '("LITTERA")) ;; ** 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 path (strcat "..\\AdminIT\\Attribut\\Export\\Littera\\")) (setq file (open (strcat Root path (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) "Dorrlittera.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 "\nExport av Dörrlittera klar från modell:\n" (getvar "DWGNAME") "\nGå till A->Attribut->Export->Littera och öppna filen Dörrlittera!!")) (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:AIX:EXPORTDORRLITT () (gattexdorr) (princ)) 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.