activate drawing after open

Discussion in 'AutoCAD' started by elise_moss, Mar 11, 2005.

  1. elise_moss

    elise_moss Guest

    I am writing a lisp routine that opens a drawing file. It opens fine. However, if I have other drawings open, whatever drawing that is open at the time I run the lisp routine remains the active drawing.

    I have the following problems:

    1) I need to activate the drawing I just opened
    2) When I activate the drawing, it loses contact with the lisp routine that was running and basically "breaks".

    I have gone through the archives and have tried various code snippets, but so far nothing works. I am in AutoCAD 2005 and it looks like vla-activate is no longer available to me (at least it isn't listed in help). The vb statements don't seem to work because of the dwg switch.

    Help?

    Elise Moss
    www.mossdesigns.com
     
    elise_moss, Mar 11, 2005
    #1
  2. elise_moss

    mkaufhold Guest

    Do you really need to have other drawings open? What about setting SDI to 1 and lispinit to 0? Then you could open drawing after drawing with your lisp (but only one at a time) and it will not quit on you.

    Hope this helps.
     
    mkaufhold, Mar 11, 2005
    #2
  3. elise_moss

    elise_moss Guest

    I don't want to annoy my users by making them close all their files simply to plot a drawing package.

    My other option would be to use a VB program to "supervise" the entire transaction.
     
    elise_moss, Mar 11, 2005
    #3
  4. Because LISP programs are part of each document they're
    run in, a LISP program cannot operate in the manner you
    describe (change the active document and continue to run).

    When a document in which a LISP program is running is
    deactivated, the running LISP program in that document
    becomes suspended until the document is active again.

    To do this sort of thing, you must use VBA.
     
    Tony Tanzillo, Mar 11, 2005
    #4
  5. elise_moss

    mkaufhold Guest

    I can understand that. Thought I would make the suggestion anyway (I'm still quite the novice). Hopefully some others will chime in with ideas.
     
    mkaufhold, Mar 11, 2005
    #5
  6. You can use this function:

    Code:
    (defun active-dwg	(fName / docs)
    (vlax-for doc	 (vla-get-documents (vlax-get-acad-object))
    (setq docs (cons doc docs)))
    (not
    (vl-catch-all-error-p
    (vl-catch-all-apply
    'vla-put-activeDocument
    (list
    (vlax-get-acad-object)
    (vl-some
    (function (lambda (item)
    (if (eq (vla-get-fullName item) fName)
    item)))
    docs))))))
    
     
    Luis Esquivel, Mar 11, 2005
    #6
  7. elise_moss

    ECCAD Guest

    What I do:
    Have the Lisp output a script, and at end,
    run that script.
    (assuming SDI 0)
    Script needs to look like:
    QSAVE
    CLOSE
    OPEN
    FILE-TO-PLOT
    (LOAD "PLOTME")
    CLOSE
    OPEN
    FILE-TO-PLOT
    (LOAD "PLOTME")
    .....ETC


    Bob
     
    ECCAD, Mar 11, 2005
    #7
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.