Why doesn't (command "_open") work?

Discussion in 'AutoCAD' started by 2k5drawer, Jan 15, 2005.

  1. 2k5drawer

    2k5drawer Guest

    Hello,

    I have a simple lisp file to open a drawing and since switching to 2005 from 2002 it no longer works. Can someone enlighten me?

    (defun c:OP (/)
    (command "_open")
    )

    I know you could modify the pgo to do this, but I don't understand why it does not work.

    Regards
     
    2k5drawer, Jan 15, 2005
    #1
  2. 2k5drawer

    2k5drawer Guest

    Never mind. I found the answer.

    "The "Open" command will not work in MDI mode.

    Regards
     
    2k5drawer, Jan 15, 2005
    #2
  3. 2k5drawer

    Bill DeShawn Guest

    (defun cmdOpen (name)
    (vl-load-com)
    (if (= 0 (getvar "SDI"))
    (vla-activate (vla-open (vla-get-documents (vlax-get-acad-object))
    name))
    (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object))
    (strcat "(command \"_.OPEN\")\n" name "\n") )
    )
    )

    This will search the ACAD environment for the drawing that you enter as an
    argument.

    Using this at the command line you use the following syntax:
    (cmdopen "test")
    No need to use the DWG extension.
    You can make it work like a command with another command function:
    (defun c:cmdopen (/ dwgnam)
    (setq dwgnam (getstring "\nDrawing name. No DWG extension required: "))
    (setq dwgnam (strcat dwgnam ".dwg"))
    (cmdopen (findfile dwgnam)); findfile might not be nec.
    (princ)
    )
     
    Bill DeShawn, Jan 16, 2005
    #3
  4. 2k5drawer

    BillZ Guest

    I received this here at the NG.

    Code:
                   ;;R.Robert Bell
    (defun CmdOpenDwgNow (fqnName / oldCmdEcho)
    (setq oldCmdEcho (getvar "CmdEcho"))
    (setvar "CmdEcho" 0)
    (command "._VBAStmt" (strcat "AcadApplication.Documents.Open \"" fqnName "\"")
    )
    (setvar "CmdEcho" oldCmdEcho)
    (princ)
    )
    (princ)
    I load it in my acaddoc.lsp and call it if sdi = 0.

    Bill
     
    BillZ, Jan 17, 2005
    #4
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.