I may be 'Complaining about Loading the Dishwasher'
I'm extracting attributes from drawing borders with DBX , ie accessing the drawing dataBase directly without opening the drawing.
Each drawing has a border with 65 attributes which are extracted and <for testing> written to a text file with the same base name as the drawing.
The test I've used is 132 drawings totalling about 19MB and writing about 950 text characters to each text file < total of 129 KB>
This is the current result ; about 0.130 seconds each :
Command: test
132 Files completed in 17.0940 seconds.
Command:
I was looking at the (VLAX-FOR Obj (VLA-GET-MODELSPACE dbx-iacaddocument) ...
which steps through each modelspace object, even after the target block is found.
The quandry is "is there an easier, faster way to do this" ?
Seems to me I could count the database items,
step through the database using 'item' to query the object, increment the counter,
repeat, repeat, then skip-out when the block is found ..
I'll probably test that tomorrow, but in the mean-time, does anyone have any other ideas, or see any bottlenecks I've missed ..
...
;; DBX_Testing.LSP
;; kwb 20061114
;;;-------------------------------------------------------------------
;;;
(DEFUN c:test (/ BorderName FileList Path start finish)
(SETQ BorderName "BORDER*"
FileList (DOS_GETFILEM
"Select files"
(GETVAR "dwgprefix")
"Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
)
)
(SETQ Path (CAR FileList)
FileList (CDR FileList)
)
(SETQ start (GETVAR "millisecs"))
(FOREACH docname FileList
(kdub:getBDXAttributes (STRCAT Path docname) BorderName)
)
(SETQ finish (GETVAR "millisecs"))
(PROMPT (STRCAT "\n "
(ITOA (LENGTH FileList))
" Files completed in "
(RTOS (/ (- finish start) 1000.0) 2 4)
" seconds."
)
)
(PRINC)
)
;;;-------------------------------------------------------------------
;;;
(DEFUN kdub:getBDXAttributes
(dwgFileName BlockName / att attlst dbx-iacaddocument fdesc_id)
(SETQ AttLst nil)
;; Assume the file is not in the current Document Collection
(SETQ dbx-iacaddocument (KDUB:OPENDBXDOCUMENT dwgFileName))
;;
(VLAX-FOR Obj (VLA-GET-MODELSPACE dbx-iacaddocument)
(IF (AND (= (VLA-GET-OBJECTNAME Obj) "AcDbBlockReference")
;; (VLA-GET-HASATTRIBUTES Obj) ;; qualifies by definition
(WCMATCH (STRCASE (VLA-GET-NAME Obj)) BlockName)
)
(SETQ AttLst (CONS (MAPCAR '(LAMBDA (Att)
(CONS (VLA-GET-TAGSTRING Att)
(VLA-GET-TEXTSTRING Att)
)
)
(VLAX-INVOKE Obj 'GetAttributes)
)
AttLst
)
)
)
)
(OR AttLst (SETQ AttLst '(" ")))
;;
;; Release the DBX database
(VLAX-RELEASE-OBJECT dbx-iacaddocument)
;;
;; Write data to file.
(SETQ fdesc_id (OPEN (STRCAT dwgFileName ".txt") "W"))
(WRITE-LINE (VL-PRINC-TO-STRING (CAR AttLst)) fdesc_id)
(SETQ fdesc_id (CLOSE fdesc_id))
;;
;;
)
;;;-------------------------------------------------------------------
;;;
;;; Open a dbx Document
;;;
(DEFUN kdub:OpenDbxDocument (DbxdwgName /
acadver DBXserver
dbxopenCatchit dbxDoc
IAcadApplication
IAcadDocument
)
(SETQ DbxdwgName (STRCASE DbxdwgName)
acadver (ATOI (GETVAR "acadver"))
IAcadApplication (VLAX-GET-ACAD-OBJECT)
IAcadDocument (VLA-GET-ACTIVEDOCUMENT IAcadApplication)
)
(COND ((= DbxdwgName (STRCASE (VLA-GET-FULLNAME IAcadDocument)))
(PROMPT (STRCAT "\nUnable to interface to ActiveDocument "
DbxdwgName
" as DBX Drawing."
)
)
)
((SETQ
dbxDoc (IF (< acadver 16)
(VLA-GETINTERFACEOBJECT IAcadApplication
"ObjectDBX.AxDbDocument"
)
(VLA-GETINTERFACEOBJECT
IAcadApplication
(STRCAT "ObjectDBX.AxDbDocument." (ITOA acadver))
)
)
)
(IF (VL-CATCH-ALL-ERROR-P
(VL-CATCH-ALL-APPLY 'VLA-OPEN (LIST dbxDoc DbxdwgName))
)
(SETQ dbxDoc nil)
)
)
)
(IF (NOT dbxDoc)
(PROMPT (STRCAT "\nUnable to determine interface to DBX Drawing "
DbxdwgName
)
)
)
dbxDoc
)
;;;-------------------------------------------------------------------
;;;