Saving variables to dwg

Discussion in 'AutoCAD' started by bnarum, Sep 17, 2004.

  1. bnarum

    bnarum Guest

    hello all
    I would like to prompt user for initial value of variable then save back to dwg, not AutoCAD. I use setenv for certain variables but for this one I want it saved with the dwg so it only prompts one time not each time the dwg is opened.
     
    bnarum, Sep 17, 2004
    #1
  2. bnarum

    ECCAD Guest

    Try this approach.

    ;; Save variable to drawing
    (defun save_to_dwg ()
    (if (= (getvar "USERS1") "")
    (progn
    (setq str (getstring "\nType in a Variable to save to Users1:"))
    (if str
    (setvar "USERS1" str)
    )
    )
    )
    )
    ;; In startup..do
    (save_to_dwg)

    ;; Note: there are (5) USERSx variables.

    Bob
     
    ECCAD, Sep 18, 2004
    #2
  3. bnarum

    Fatfreek Guest

    Hmmm ... unless I missed something, the USERSX variables have NEVER been
    able to remember strings from session to session.

    Search on dictionary for one technique.

    Len Miller
     
    Fatfreek, Sep 18, 2004
    #3
  4. bnarum

    ECCAD Guest

    Fatfreek,
    (what a handle).
    I was under the impression that the UsersX var's would be
    saved in the drawing - along with other sysvar's.
    You are correct. Not the case. I guess I'll have to dream up
    another method. Maybe a block with a couple of attributes,
    and no visible entities.

    Thanks for pointing that out.

    Bob
     
    ECCAD, Sep 18, 2004
    #4
  5. bnarum

    Fatfreek Guest

    I hope I didn't come across that USERR1 (reals) thru ...5 and USERI1
    (integers) thru ... 5 had that same deficiency. Those can survive saves.
    Fact is, I used USERR1 for years storing drawing settings by virtue of
    values. A value of 25000.0 meant the drawing was metric -- 10000.0 meant
    inches, etc, etc. Not very direct, but it worked.
    Thanks to tips on this forum I now use dictionary entries -- yes, they're
    hidden and not attached to visible entities, but easier to place information
    and get information.
    There are other techniques, I was told, but that was the one I chose.

    Len
     
    Fatfreek, Sep 19, 2004
    #5
  6. bnarum

    liftedaxis Guest

    though the USER strings are not saved session to session, you'll notice the HYPERLINKBASE sysvar *is* saved. If you can safely assume you'll never need to use this sysvar, you can go ahead and save your custom data here.

    --Jeremiah
     
    liftedaxis, Sep 19, 2004
    #6
  7. bnarum

    John Uhden Guest

    Take a look at the (dictxxx) functions in the acad_dev.chm help file.




    dwg, not AutoCAD. I use setenv for certain variables but for this one I want it
    saved with the dwg so it only prompts one time not each time the dwg is opened.
     
    John Uhden, Sep 19, 2004
    #7
  8. bnarum,

    Just guessing here, but what "DICTADD".

    Doesn't that save strings/nongraphical data?

    But upon reopening the file, 'startup' would have to read "DICTSEARCH" and
    invoke that variable.

    W. Kirk Crawford
    Rochester Hills, Michigan
     
    W. Kirk Crawford, Sep 19, 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.