How to set opened document Active with VL.

Discussion in 'AutoCAD' started by ECCAD, Aug 14, 2004.

  1. ECCAD

    ECCAD Guest

    Maybe a 'uninformed' question, but, I want to open a read-only drawing - using VLisp and set it to the 'current' drawing in the editor. I have a drawing open, and am in SDI = 0 mode.

    What does the code look like if the drawing = "test.dwg".

    Bob
    EC-CAD
     
    ECCAD, Aug 14, 2004
    #1
  2. ECCAD

    ECCAD Guest

    So far I have:

    (vl-load-com)
    (command "SDI" 0)
    (setq fname (findfile "test.dwg"))
    (if fname
    (progn
    (setq doc (vla-open (vla-get-documents (vlax-get-acad-object)) fname))
    (vlax-release-object docs)
    ); end progn
    (prompt "\nCould not find the Test.dwg ?? ")
    ); end if
    (princ)

    It opens the test.dwg (it's on a support path), but it does not
    set it the 'current' drawing. It just adds it to the 'History' list.

    Bob
     
    ECCAD, Aug 14, 2004
    #2
  3. ECCAD

    Mark Propst Guest

    (defun test()
    (setq fname"Z:\\0\\0Dwgs\\testdwgs\\stairtest.dwg")
    (setq doc (vla-open (vla-get-documents (vlax-get-acad-object)) fname))

    ;this activates doc but leaves vlide stuck in previous drawing(from where
    lisp was run)
    ;(vlax-invoke-method doc 'activate)

    ;this activates doc and seems to free up lisp from previous doc
    ;method gleaned from Jason Piercey - thanks dude!
    (command "vbastmt" "documents.item(documents.count - 1).activate")

    ; i thought maybe this would work but it didn't
    ;(command "vbastmt" (strcat "documents.item(" fname ").activate"))
    )

    hth
    Mark

    fname))

    (command "vbastmt" "documents.item(documents.count-1).activate")
     
    Mark Propst, Aug 14, 2004
    #3
  4. ECCAD

    ECCAD Guest

    Mark,
    Thanx. This works fine.
    (command "vbastmt" "documents.item(documents.count - 1).activate")

    Bob
    http://www.bobscadshop.com
     
    ECCAD, Aug 14, 2004
    #4
  5. ECCAD

    Mark Propst Guest

    Cool.
    too bad there's not a cleaner way - without command - but till then...
    :)
     
    Mark Propst, Aug 14, 2004
    #5
  6. ECCAD

    Doug Broad Guest

    Hi Mark,
    Slightly simpler versions:
    (command "vbastmt" "documents.open \"test.dwg\",true")
    or
    (vl-cmdf "vbastmt" "documents.open \"test.dwg\",true")

    It is important to realize that, as soon as either of those statements are
    executed, that the lisp program in the launching document is suspended
    and does resume execution until that document is reactivated.
     
    Doug Broad, Aug 14, 2004
    #6
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.