TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Guest on July 20, 2007, 09:49:49 AM
-
Anyone have any good, simple, easy to read literature on using DBX to "read" stuff in drawings? I'm looking to do some kind of batch routine, but first I need to get the layout names of selected drawings.
-
ObjectDBX is "undocumented". However, for the most part, you can use any activex methods on a dbxDocument that you can on an acdbDocument. Just substitute the pointer for the dbxDocument for (vla-get-activedocument(vlax-get-acad-object)).
(vla-get-modelspace dbxDoc)
(vlax-get dbxDoc 'textstyles)
The only method not available to dbx is save - there is a saveas.
The best way to learn is through trial and error. Doa search for dbx - there are some examples.
-
This is what I've got so far (my meager attempt). It would be so much easier for me to do this in VBA, but I want to eventually throw this into a ODCL form and use some of the cool controls. :-)
(defun C:DBXTest ( / dbxDoc strFileName)
(setq dbxDoc (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument.16"))
(setq strFileName "e:/temp/DBX.dwg")
(vla-open dbxDoc strFileName)
; Need code to determine layout tab names...
(vlax-release-object dbxDoc)
)
I've read somewhere that you shouldn't mix VLisp code and/or functions and regular LSP code and/or functions. Is this true?
-
This might help ya
(defun c:dbxdump (/ app dbxdoc dbxopen doc dwgname file)
(vl-load-com)
(setq app (vlax-get-acad-object)
doc (vla-get-ActiveDocument app)
dwgname "C:\\Drawing1.dwg"
)
(if (< (atoi (getvar "AcadVer")) 16)
(setq file "ObjectDBX.AxDbDocument")
)
(if (= (atoi (getvar "AcadVer")) 16)
(setq file "ObjectDBX.AxDbDocument.16")
)
(if (= (atoi (getvar "AcadVer")) 17)
(setq file "ObjectDBX.AxDbDocument.17")
)
(if (/= dwgname (vla-get-fullname doc))
(progn
(setq dbxDoc (vla-GetInterfaceObject app file)
dbxopen (vl-catch-all-apply 'vla-open (list dbxDoc DwgName))
)
(if (vl-catch-all-error-p dbxopen)
(setq dbxDoc nil)
)
)
)
(vlax-dump-object dbxDoc 'T)
(if (= (type dbxDoc) 'VLA-OBJECT)
(progn
(vlax-release-object dbxDoc)
(setq dbxDoc nil)
)
)
)
-
The attached PDF may or may not help you in learning ObjectDBX. Take a look at Chapter 14.
Nick
-
ActiveX is almost the same as VBA. If you know how to do it in VBA, then you should know how to do it in Lisp with ActiveX. The difference is the way you call the functions. Once you have your document (Doc), and you want to get the layouts, then you just grab the layout collections, and step through it, and grab the names.
(vlax-for Layout (vla-get-Layouts Doc)
(setq LayoutNameList (cons (vla-get-Name Layout) LayoutNameList))
)
-
This is how I get the DBXdoc:
(setq v (substr (getvar 'acadver) 1 2)
doc (vlax-get-acad-object)
odbx (if (< vnum "16")
(vla-GetInterfaceObject doc "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject
doc
(strcat "ObjectDBX.AxDbDocument." v)
)
)
)
Ron