Author Topic: Crash course in DBX  (Read 3277 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Crash course in DBX
« 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.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Crash course in DBX
« Reply #1 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.
James Buzbee
Windows 8

Guest

  • Guest
Re: Crash course in DBX
« Reply #2 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?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Crash course in DBX
« Reply #3 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)
  )
 )
)


HD

  • Guest
Re: Crash course in DBX
« Reply #4 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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Crash course in DBX
« Reply #5 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))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Crash course in DBX
« Reply #6 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

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC