ObjectDBX

Discussion in 'AutoCAD' started by Sa Mite Samite, Feb 5, 2004.

  1. Object DBX vla-open method opens a file and vlax-release-object method
    release the variable space in the memory. Now. How to CLOSE the opened
    drawing file? vla-Close method does not work with this type of object and my
    drawing stays opened until I shutdown the AutoCAD.

    Thanks,
    Sam
     
    Sa Mite Samite, Feb 5, 2004
    #1
  2. Sa Mite Samite

    Doug Broad Guest

    There is no close method for objectdbx.
    You could consider the objectdbx file like a temporary file.
    If you want to save it, then use vla-saveas. To open a new
    file just use vla-open again.
     
    Doug Broad, Feb 5, 2004
    #2
  3. You just said it :)

    (vlax-release-object)

    Assuming there are no other outstanding references to
    the AxDbDocument, when you call (vlax-release-object)
    on the AxDbdocument, it closes the file and releases
    any locks on it.



    vla-Close method does not work with this type of object and my
     
    Tony Tanzillo, Feb 5, 2004
    #3
  4. Sa Mite Samite

    Mark Propst Guest

    Doug and Tony pointed out how to close a dbx doc.
    Even after learning the how, I still found myself more comfortable with a
    reasurring looking statement like (closeDBX oDbxDoc) that would return a
    comforting message telling me it worked. Guess this classifies as psychotic
    ....I mean psychological... programming :)
    so I can go like
    (if (closeDBX oDbxDoc "save" "savedByDbx.Dwg")(alert"now i can sleep at
    night")(alert"hmmm....now what did I do wrong?"))
    ; gleaned from various ng posts, modified ...or is that mutilated...by mark
    propst
    ; thanks to Tony Tanzillo, Luis Esquivel, Michael Puckett, Frank Oquendo,
    James Buzzbee, Doug Broad et al
    ; for their unselfish generosity in sharing their knowlege about this
    undocumented feature set
    ; Especial thanks to Tony for his many examples which show even a dummy like
    me how to use Dbx
    ;google is a goldmine of info on objectDBX
    ;whatever is lame in the following code is totally my doing
    ;whatever is good is due to the above mentioned contributors and others
    posts
    ; Closes a dbx Document and saves or not.
    ; Called thus:
    ; (CloseDbx oDbxDoc 1 "path\\NewName.Dwg"); to save as a new name
    ;(CloseDbx oDbxDoc 1 nil); to save as existing name
    ;(CloseDbx oDbxDoc nil nil); to close but not save
    ;Returns nil on error or failure, 1 on success
    (defun CloseDbx (inDoc saveYes fname / res )
    (if
    (and
    inDoc
    ;(=(Type inDoc)'VLA-OBJECT)..or something to that effect
    (not(vlax-object-released-p inDoc))
    );and
    (progn
    ;if asked to save, do so
    (if SaveYes
    (saveDbx inDoc fname)
    ) ;try to release object
    (if(vl-catch-all-error-p
    (vl-catch-all-apply
    'vlax-release-object (list inDoc)
    )
    (progn
    ;(princ"\n*****Error releasing Dbx document*****");just for
    debugging sake
    nil;return nil on error
    );pro
    ;else clean up
    (progn
    ;(prind"\nDbx document released") ;just for debugging sake
    (gc)(gc);i saw this posted by people who should know so it's got to be
    a good thing! :)
    1;return 1 on success
    ) ;pro
    );if
    );pro
    (progn
    ;(prind"Object nil or already released");just for debugging
    nil
    );pro
    );if
    rtn
    );close

    ;based on original code from james buzbee's versions
    (defun saveDbx (object oname / res fname)
    (or (setq fname oname);if name arg is not nil, try to use it
    (setq fName(vlax-get-property object 'name));else use existing document
    name
    )
    (if
    (vl-catch-all-error-p
    (vl-catch-all-apply
    'vlax-invoke-method (list object 'saveas fName)
    ))

    (progn
    ;(print"Error saving Dbx")
    nil;return value of nil for failure
    );progn
    (progn
    ;(princ(strcat "\nSuccessfully saved Dbx: " fname));debug
    1;return value of 1 for success
    );progn
    );if
    )

    hth
    Mark
     
    Mark Propst, Feb 5, 2004
    #4
  5. Sa Mite Samite

    Mark Propst Guest

    oops couple typos
    as i was posting i rewrote the routine eliminating a couple variables i had
    used in debug stage
    i missed a couple excisions
    is now:

    (defun CloseDbx (inDoc saveYes fname)

    and
    is now:
    fwiw
     
    Mark Propst, Feb 5, 2004
    #5
  6. Sorry, but I really don't see the point to this.

    Why do you feel that you need to be reassured
    that the document was closed?

    Have you had this problem since birth? :)
     
    Tony Tanzillo, Apr 15, 2004
    #6
  7. You don't close an AxDbDocument. You just discard it,
    by releasing the variable assigned to it.
     
    Tony Tanzillo, Apr 15, 2004
    #7
  8. Sa Mite Samite

    Mark Propst Guest

    "Tony Tanzillo" <tony.tanzillo/at/caddzone/dot/com> wrote in message

    yep, like i said "... this classifies as psychotic..."
    for the simple fact that since nearly everything i do is wrong I feel like i
    need to confirm every line!

    yep, that and a lot more besides!
    :)

    where did you dig that old post up anyway? that was like a year ago or
    something wasn't it? and I thought *I* had a slow connection!... :)
     
    Mark Propst, Apr 15, 2004
    #8
  9. where did you dig that old post up anyway? that was like a year ago or

    Hmmm.. It looks like the dates on the messages aren't
    right in my newsreader. I reset and downloaded the
    newsgroup again, and that fixed it.
     
    Tony Tanzillo, Apr 16, 2004
    #9
  10. Sa Mite Samite

    Mark Propst Guest

    hey...it's always good to hear from you....even months later!
    :)
     
    Mark Propst, Apr 16, 2004
    #10
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.