Thanks
Jason
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...
;;; 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...