Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extracting Attribute Information

80 views
Skip to first unread message

Jason Benskin

unread,
Jan 24, 2002, 7:59:24 AM1/24/02
to
I have been trying to use the new Attribute Extract tool with Acad 2002. I
would like to come up with a simple script or a lisp routine that will
extract my border information for me, so I can keep my dwg index updated for
my job. I am able to get the new extract tool to work, however you cannot
extract specific information in mass. Mainly I am looking to extract my dwg
titles and dwg no's to an excel file. If I try using the select files
method it tells me which files my attribute reside in, but will not give me
the extra information. Any help here will be much appreciated.

Thanks
Jason


Tony Tanzillo

unread,
Jan 24, 2002, 8:31:32 AM1/24/02
to
You can't really script the attribute extract tool.

You could use ObjectDBX from LISP to access drawings without
opening them in the drawing editor. See the following file
for more info:

http://www.caddzone.com/vl-dbx.zip

"Jason Benskin" <benski...@stanleygroup.com> wrote in message
news:7673941D6DD5661D...@in.WebX.maYIadrTaRb...

Joe Funk

unread,
Jan 31, 2002, 1:46:03 AM1/31/02
to
Jason;
I don't know about -EATTEXT in a script, but you can use it in a
LISP. Below is a routine that does that. It needs error handling, but
otherwise it works OK. I hope you can use it.
I wish there were some documentation on the command line version, and
better error reporting in general when EATTEXT runs into a problem.
Joe

;;; EATTEXT test.lsp
;;;
;;; A try at using LISP to control EATTEXT. The function
;;; (eaprint) prints the output from EATTEXT to file formats
;;; Csv/Txt/Xls/Mdb. It works OK, but it needs error-handling.
;;;
;;; Joe Funk May 01-01
;;;
;;; Last edited Jan.30-02
;;;
;;; Notes ..................
;;;
;;; EATTEXT works on R14 dwgs as well as R15.
;;;
;;; At the command line, if option "Select dwgs" is chosen, the next
;;; prompt is "Enter a drawing file or list of drawing files separated
;;; by "," and press ENTER:"
;;; - in a LISP, this requires a concatenated string such as:
;;; "Tbasef.dwg,2PMH.dwg,xbindtest.dwg"
;;; - if a folder is on AutoCAD Support path, the path isn't required
;;;
;;; The string length limitation is apparently 4048, including path,
;;; file name, dot, extension, double quotes and spaces in file names.
;;;
;;; EATTEXT supplies the appropriate extension automatically; in fact
;;; your extension is ignored if you enter one.
;;; eg. If you ask for an output file "test.ttt" for an Access output
;;; file, the filename is forced to "test.mdb"
;;; Similarly, "test" and "test." are forced to "test.mdb"
;;;
;;; Sample "output filetype" sizes for a small selection of attributes:
;;; "Csv" (Comma Separated Values) --> comma-delimited text 16k
;;; "Txt" --> tab-delimited text 17k
;;; "Xls" --> Excel 70k
;;; - "Mdb" --> Access 114k
;;;
;;; When called in a LISP, -EATTEXT apparently requires use of a
;;; template. The prompt is "Enter Template file path" - this needs a
;;; path\filename.blk as answer. The template file can be created using
;;; the EATTEXT dialog.
;;;
;;;======================================================================
;;;

(vl-load-com)

;;;
;;;**********************************************************************
;;;
;;; I'm using CMDLGD.DLL just for getting the source dwgs for -EATTEXT.
;;; This avoids manually registering it:
;;;(startapp "c:/windows/system/regsvr32.exe"
;;; (strcat "/s \"" "C:/UTILITIES/CMDLGD.dll" "\"")
;;;)
;;;
;;;**********************************************************************
;;;
;;; Thanks to Frank Oquendo for showing us this.
;;;

(defun SelectFiles (Title Filter Flags / o-Dialog sDir sFiles iCount)
(setq o-Dialog (vlax-create-object "CommonDialogDirect.cCommonDialog"))
(vlax-put-property o-Dialog 'DialogTitle Title)
(vlax-put-property o-Dialog 'Filter Filter)
(vlax-put-property o-Dialog 'Flags Flags)
(vlax-invoke-method o-Dialog 'ShowOpen)
(vlax-invoke-method o-Dialog 'ParseMultiFileName 'sDir 'sFiles 'iCount)
(vlax-release-object o-Dialog)
(setq MFiles
(mapcar '(lambda (x)
(strcat sDir "\\" x)
)
(vlax-safearray->list sFiles)
)
)
)

;;;
;;;============================== End SelectFiles =======================
;;;
;;; Function: C:EAPRINT
;;;
;;; Needs error handlers for these situations, at least:
;;; 1. A dwg in the list is currently open in the editor.
;;; 2. None of the dwgs selected contain blocks. "No blocks in file."
;;; 3. Since sysvar EXPERT doesn't seem to work, if output filepath
;;; already exists, must answer this prompt:
;;; "File <eatest.csv> already exists.
;;; Do you want to replace it? [Yes/No] <Y>:"
;;; - if "Y", file is overwritten
;;; - if "N", must supply a different output filepath
;;; So, need to check beforehand (eg. w/ findfile) whether it
;;; exists, and act accordingly ... or maybe use this:
;;; (while cmdactive (command "")) to cause overwrite if exists.
;;;
;;; Local Variables
;;;
;;; SRCFILES (list) - of all dwgs selected (full path + extension)
;;; STR_DWGLST (str) - same, turned into a string
;;;
;;;----------------------------------------------------------------------
;;;

(defun C:EAPRINT (/ SRCFILES STR_DWGLST TEMPLATE OUTPUT)
(setq SRCFILES
(SelectFiles
"Select drawings" "AutoCAD drawings (*.dwg)|*.dwg" 2626052
)
)
;;; (princ "\nSRCFILES: ")(princ SRCFILES)
(cond
(SRCFILES
(setq STR_DWGLST "")
(foreach dwg SRCFILES
(setq STR_DWGLST (strcat (strcat dwg ",") STR_DWGLST))
)
(setq STR_DWGLST
(vl-string-left-trim "\\" (vl-string-right-trim ","
STR_DWGLST))
TEMPLATE "D:\\DEVELOP\\Softco\\DRAWINGS\\R2000\\allR2000.blk"
OUTPUT "C:\\eatest.txt"
)
)
(T (princ "\nNo files selected.") (exit))
)

;;; (princ "\nSTR_DWGLST: ")(princ STR_DWGLST)
;;; (princ "\nstrlen STR_DWGLST: ")(princ (strlen STR_DWGLST))

(command "-EATTEXT" ;Enhanced Attribute Extract cmd
"_s" ;Select dwgs
STR_DWGLST ;Enter a drawing file or list of
; drawing files separated by "," and
; press ENTER:
"_Y" ;Extract data from external
; reference drawing?
"_Y" ;Extract data from nested blocks?
TEMPLATE
;Enter Template file path
"_Txt" ;Enter the output filetype
;[Csv/Txt/Xls/Mdb <Csv>:
OUTPUT ;Enter output filepath:
)
)

;;;
;;;============================== End C:EAPRINT ============================
;;;

;;;(C:EAPRINT)


"Jason Benskin" <benski...@stanleygroup.com> wrote in message
news:7673941D6DD5661D...@in.WebX.maYIadrTaRb...

Joe Funk

unread,
Jan 31, 2002, 1:50:38 AM1/31/02
to
"The template file can be created using the EATTEXT dialog."
... before running the LISP
Joe

0 new messages