Object DBX and the Documents collection

Discussion in 'AutoCAD' started by Joe Burke, Apr 15, 2004.

  1. Joe Burke

    Joe Burke Guest

    All,

    Assuming you want to get some data from a file other than the active file, does this
    make sense? Check the Documents collection to see if the file is open. If so, get the
    data from the open file via the Documents collection. If the source file isn't open,
    use Object DBX to open it. Then get the data from the DBX file.

    Kinda seems like a dumb question. But I haven't seen code examples which do that. And
    that makes me think I'm missing something here. Maybe it's not that simple?

    What I have seen is code which assumes Object DBX should be used. When that fails,
    because the file is open, the code ends. I've done that myself. I've also seen
    messages in the VBA NG which mention the idea of copying an open source file to some
    temporary folder so Object DBX can open it. Why?

    Thanks for any insights...
    Joe Burke
     
    Joe Burke, Apr 15, 2004
    #1
  2. Joe Burke

    Joe Burke Guest

    Thanks, Jason. At least I'm on the right track. :)

    I must confess, it was only a few weeks ago I realized I can get data from files in
    the Documents collection. And appropriately enough, I stumbled on it (while Google
    searching for something unrelated) in a thread where someone informed you a couple
    years ago. What goes around...

    I sure have a lot to learn, but I'm not complaining. The discovery process is an
    enjoyable trip in itself.

    Joe
     
    Joe Burke, Apr 15, 2004
    #2
  3. Joe Burke

    Mike Weaver Guest

    This is done because the file may be open by someone else on the network.
    But you are on the right track, if the file can't be opened by ObjectDBX,
    one should check the documents collection and get it from there if found.
     
    Mike Weaver, Apr 15, 2004
    #3
  4. Joe Burke

    Joe Burke Guest

    Mike,

    I'm on shaky ground here because most of the time I'm a standalone user. So the
    following is more a question than a statement. As I understand it, the issue of
    whether a file is open under Object DBX is local to the machine trying to open it.
    IOW, if I'm machine A on a network, and machine B on the net has the file open I'm
    trying to open with DBX... that won't prevent me from opening it.

    Yes, no, maybe?

    Joe Burke
     
    Joe Burke, Apr 15, 2004
    #4
  5. Joe Burke

    Mark Propst Guest

    no, odbx can't open a read only doc, just throws error
    that's why you have to catch that error, make temp copy, then open that copy
    (regardless of who has file open)
     
    Mark Propst, Apr 15, 2004
    #5
  6. Joe - Nothing really confusing here.

    Design your code to be document agnostic, which means you
    don't write code that deals directly with an AcadDocument
    or AxDbDocument.

    Rather, design your code to work with an AcadDatabase,
    and then it can be applied to any drawing, open in the
    editor or in an AxDbDocument.

    You just pass the .Database property of the AcadDocument
    or the AxDbDocument object to the procedure that accesses
    it, and that's pretty much it.

    For that, you can use early binding:

    Public Sub GetDatabaseInfo(Doc As Object)
    Dim Db As AcadDatabase
    Set Db = Doc.Database
    ...
    End Sub

    Note that you declare the parameter as an object, which
    means it can be either an AcadDocument or an AxDbDocument,
    and then you get the .Database property of either in the
    sub.
     
    Tony Tanzillo, Apr 15, 2004
    #6
  7. Joe Burke

    Joe Burke Guest

    Tony,

    Thanks for the big picture. It will sink in eventually.

    Joe Burke
     
    Joe Burke, Apr 16, 2004
    #7
  8. Joe Burke

    Joe Burke Guest

    Mark & Mike,

    I see.

    Thanks
    Joe Burke
     
    Joe Burke, Apr 16, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.