open + time reset

Discussion in 'AutoCAD' started by caca, Oct 8, 2004.

  1. caca

    caca Guest

    Hi,
    I have been trying to change the "open" command. I wanted to open a drawing and right after it is opened, do a "time" "reset", but for me it is not working, as if "time" "reset" was simply not there at the lisp code...

    thank you,
    Carol
     
    caca, Oct 8, 2004
    #1
  2. caca

    dblaha Guest

    Set the LISPINIT system variable to 1 in your code:

    (setvar "lispinit" 1)


    Dave
     
    dblaha, Oct 8, 2004
    #2
  3. caca

    caca Guest

    I have added this line in my code, but I am with a really simple doubt about the open command: how do I write this command so I can choose the file to open, not pre define it in the code?

    Thank you
     
    caca, Oct 13, 2004
    #3
  4. caca

    dblaha Guest

    First of all, I got my lispinit advice backwards. It should be set to 0 in order for your code to keep running in the drawing you open. It's default value is 1.

    The sample code I've written below will allow the user to open a drawing with the open dialog and run code in that drawing once it's open, BUT it only works in SDI mode, which means you can only have one drawing open at a time. Also, it assumes that you do not want to save changes to your currently open drawing when you run it.

    (defun c:my_open ()
    (setq old_lispinit (getvar "lispinit"))
    (setq old_sdi (getvar "sdi"))
    (setvar "lispinit" 0)
    (setvar "sdi" 1)
    (initdia)
    (command "open" (if (> (getvar "dbmod") 0)"y"))
    (setvar "sdi" old_sdi)
    (setvar "lispinit" old_lispinit)
    (princ "Your code goes here.")
    (princ)
    )


    Dave
     
    dblaha, Oct 13, 2004
    #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.