TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Guest on July 20, 2007, 09:49:49 AM

Title: Crash course in DBX
Post 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.
Title: Re: Crash course in DBX
Post by: jbuzbee on July 20, 2007, 10:05:05 AM
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.
Title: Re: Crash course in DBX
Post by: Guest on July 20, 2007, 10:14:54 AM
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.  :-)

Code: [Select]
(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?
Title: Re: Crash course in DBX
Post by: It's Alive! on July 20, 2007, 10:30:08 AM
This might help ya

Code: [Select]

(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)
  )
 )
)

Title: Re: Crash course in DBX
Post by: HD on July 20, 2007, 11:00:50 AM
The attached PDF may or may not help you in learning ObjectDBX. Take a look at Chapter 14.

Nick
Title: Re: Crash course in DBX
Post by: T.Willey on July 20, 2007, 11:14:18 AM
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.

Code: [Select]
(vlax-for Layout (vla-get-Layouts Doc)
 (setq LayoutNameList (cons (vla-get-Name Layout) LayoutNameList))
)
Title: Re: Crash course in DBX
Post by: ronjonp on July 20, 2007, 11:30:07 AM
This is how I get the DBXdoc:

Code: [Select]
(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