redefine "new" command...

Discussion in 'AutoCAD' started by avw_410, Nov 22, 2004.

  1. avw_410

    avw_410 Guest

    I want to run a lisp file that i use to setup new files... i can't add it
    to the acaddoc.lsp file becuase it will run every time a dwg opened and i
    only want it to run when a new dwg is opened... can anyone help me???
     
    avw_410, Nov 22, 2004
    #1
  2. You could have your code in AcadDoc.lsp, but check the DwgTitled system
    variable. If the drawing is titled, don't run your code.

    --
    R. Robert Bell


    I want to run a lisp file that i use to setup new files... i can't add it
    to the acaddoc.lsp file becuase it will run every time a dwg opened and i
    only want it to run when a new dwg is opened... can anyone help me???
     
    R. Robert Bell, Nov 22, 2004
    #2
  3. avw_410

    Doug Broad Guest

    Redefining the new command won't help you as far as lisp
    is concerned. The new drawing, once activated, suspends the
    redefined new command until you return to the previous drawing.

    Instead have your code in acaddoc.lsp determine whether the
    drawing just opened is new.

    It is relatively easy to determine that a drawing is new.
    Some possibilities:
    1) Does it have any entities?
    2) Check the time variables to see how long the drawing has been
    edited. Under a minute is a guarantee that the drawing is new.

    If you want to program at the application level, rather than at the
    drawing level, then VBA is better suited.
     
    Doug Broad, Nov 22, 2004
    #3
  4. Personally, I prefer to look at DwgTitled. BwaHaHa!!!

    --
    R. Robert Bell



    It is relatively easy to determine that a drawing is new.
    Some possibilities:
    1) Does it have any entities?
    2) Check the time variables to see how long the drawing has been
    edited. Under a minute is a guarantee that the drawing is new.
     
    R. Robert Bell, Nov 22, 2004
    #4
  5. avw_410

    Doug Broad Guest

    Hi Robert.
    Good point. Either would work well.
     
    Doug Broad, Nov 22, 2004
    #5
  6. Neither of these absolutely indicates if a drawing is 'new'.

    Prototype drawings can have entities.

    Drawings can be generated automatically via programmatic means,
    and have little or no edting time associated with them.

    The DWGTITLED system variable is specfically for this purpose.
     
    Tony Tanzillo, Nov 22, 2004
    #6
  7. avw_410

    Doug Broad Guest

    Tony,
    Thanks. Didn't think about the programmatically created drawings
    not having much time in them.
     
    Doug Broad, Nov 22, 2004
    #7
  8. avw_410

    avw_410 Guest

    well, in case anyone cares... i used the dwgtitled... and an "IF"
    statement... if dwgtitled = 0 run the routine, if it = 1 do nothing...
    that works well for what i wanted to do... so now when i open an existing
    drawings it opens as normal but when i open a new drawing it runs the setup
    routine...
     
    avw_410, Nov 23, 2004
    #8
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.