Jump to content

Recommended Posts

Posted

Hi,

 

I'm new around here so, I couldn't find the solutions please don't mad me if this request already written by someone else. And also sorry about my grammer either :)

 

The thing what I want to do :

 

I have a folder and this folder is include many dwg files. And these dwg files contetnts one or more layouts. I'm using Enhanced Attribute Editor for keep data like; <drawing number>, <drawing name>, <date>, <revision no>  etc.

 

So I need a lisp for export these data to an excel file .

 

thanks in advance for any help 

Truly Regards

 

Posted

Have you tried using the standard AutoCAD DATAEXTRACTION command?

Posted

Another simple is a lisp extract attributes to csv file. Just search.

Posted (edited)

Express Tools ATTOUT and ATTIN command? I have used these in the past with good results. ATTOUT creates a tab delimited text file, which can be imported by Excel.

Edited by pkenewell
Posted
On 10/1/2019 at 6:56 PM, Lee Mac said:

Have you tried using the standard AutoCAD DATAEXTRACTION command?

Data extractiontools wasn't enough cause if someone change the  values which in the enhanced attribute editor. I wanna run the lisp and create an excel file in the same folder which include all enhanced attribute editor values. and some dwg has a more than one layout and almost all layout include an enhanced attribute editor.

 

 

Posted
On 10/2/2019 at 5:01 AM, BIGAL said:

Another simple is a lisp extract attributes to csv file. Just search.

I think you talked about this am I right? 

How could I run tis code, cause it has no  c  shortcut

and when I trid to run this in vlisp untitled project 

"quit / exit abort" error comes on my front :)

; 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 '("ENG"))
 ;; ** edit to include block names to select
 (setq TagList '("WEIGHT" "LABEL" ))
 ;; ** 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 "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)

 

Posted
16 hours ago, pkenewell said:

Express Tools ATTOUT and ATTIN command? I have used these in the past with good results. ATTOUT creates a tab delimited text file, which can be imported by Excel.

I know actually this two command but like I said there is too many layouts in dwg and too many dwg in folder. when some changes happend in enhanced attribute editor.I wanna run the command (after delete old xls file) to creare my new xls file which include alll current values  :) 

Posted (edited)

If I understand correct you want the title block details exported for a multi layout dwg plus other info like dwg name, but it needs to process over a directory of dwgs.

 

Just need the  title block name, if you do not want all attributes then tag names required.

 

An example change block name

 


 

(defun c:test ( )

(setq blkname "DA1DRTXT")
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
(setq lname (vla-get-name lay))
(princ "\n")
(princ (strcat "layout = " lname))
(if (/= lname "Model")
(progn
(setvar 'ctab lname)
(setq ss  (ssget "x" (list (cons 0 "insert")(cons 2 blkname)(cons 410 lname))))
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS 0 )) 'getattributes)
(princ (strcat  (vla-get-tagstring att) "," (vla-get-textstring att)))
(princ "\n" )
)
)
)
)

)

(c:test)

[/code]
 

Edited by BIGAL

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...