Saving avariable to a dwg file

Discussion in 'AutoCAD' started by chrisb, Jan 27, 2004.

  1. chrisb

    chrisb Guest

    I have a little routine (given to me by Dean S - I can never remember how to spell his last name- and taken a few steps further by me) that saves a dwg to 2 locations (for a sort of almost real-time incremental backup). I've added some crude enhancements to it, so that it asks for the alternate path for saving (and stores it globally to a variable). This way, as long as I haven't closed the file, the routine now gives me the opportunity to accept that path (now stored in the variable) for each subsequent save, so I don't have to keep pasting it in with each new save (crude, yes, but it works well enough for now) - What would be better though, would be to be able to save that path to the dwg file (the path will always be the same for that file) so that once it's been established for that dwg, it never has to be supplied to the routine again (but can be changed, if necessary).
    Since the path is neither an integer or a string, I can't use the USER|* variables. Is there any other way to do this? Thanks for any useful input.
    -Chris
     
    chrisb, Jan 27, 2004
    #1
  2. chrisb

    ECCAD Guest

    See system variable "DWGPREFIX".
    e.g.
    (setq Path (getvar "dwgprefix"))

    Bob
     
    ECCAD, Jan 27, 2004
    #2
  3. You might save the path in a .TXT file (or any file name such as
    C:/temp/savefile.dir).
    Same code -
    (setq FN "C:/temp/savefile.dir")
    (if (findfile FN)
    (progn
    (setq F1 (open FN "r"))
    (if F1
    (progn
    (setq SAVEPATH (read-line F1))
    (close F1)
    )
    )
    )
    (progn
    (setq SAVEPATH "")
    (while (= SAVEPATH "")
    (setq SAVEPATH (getstring "\nInput Save Path folder using forward
    slashes ? "))
    )
    (setq F1 (open FN "w"))
    (write-line SAVEPATH F1)
    (close F1)
    )
    )

    to spell his last name- and taken a few steps further by me) that saves a
    dwg to 2 locations (for a sort of almost real-time incremental backup). I've
    added some crude enhancements to it, so that it asks for the alternate path
    for saving (and stores it globally to a variable). This way, as long as I
    haven't closed the file, the routine now gives me the opportunity to accept
    that path (now stored in the variable) for each subsequent save, so I don't
    have to keep pasting it in with each new save (crude, yes, but it works well
    enough for now) - What would be better though, would be to be able to save
    that path to the dwg file (the path will always be the same for that file)
    so that once it's been established for that dwg, it never has to be supplied
    to the routine again (but can be changed, if necessary).
    variables. Is there any other way to do this? Thanks for any useful input.
     
    Alan Henderson, Jan 27, 2004
    #3
  4. Do a search for DWGVAR.LSP

    ; DWGVAR.LSP Copyright 1992-1999 Tony Tanzillo All Rights Reserved
    ;
    ;
    ; DWGVAR.LSP
    ;
    ; Tony Tanzillo
    ; Design Automation Consulting
    ;
    ; (First implemented on September 28, 1991)
    ;
    ; Requires AutoCAD Release 11 or greater.
    ;
    ; DWGVAR.LSP
    ;
    ; API and toolkit for implementing application-defined drawing variables.
    ;
    ; DWGVAR.LSP is a generic application programming toolkit and interface
    ; that implements "drawing variables", allowing any AutoLISP application
    ; to easily define its own "variables" in drawings, and assign/reference
    ; their values via application-defined names.
     
    Allen Johnson, Jan 27, 2004
    #4
  5. chrisb

    ECCAD Guest

    Or,
    After save (file1), get 'alternate' path. Insert a 'block' with just (1) invisible attrib - say AltPath.dwg, with 'path' tag. Store the Alternate Path into the attrib. Next time in, check for block AltPath, grab attrib value, and use (strcat path ".dwg"), then save there .??
    Bob
     
    ECCAD, Jan 27, 2004
    #5
  6. chrisb

    Thomas Smith Guest

    I like this method, but you could also attach X-Data to a line or block...
    Or something as simple as a text entity that is in a layer w/ no plot set
    (or just put the text on the defpoints layer)

    The attribute or text would the the easiest to re-define... The X-Data would
    have to be added & changed programatically.
    I guess it's all a matter of how easy you want it all to be.


    invisible attrib - say AltPath.dwg, with 'path' tag. Store the Alternate
    Path into the attrib. Next time in, check for block AltPath, grab attrib
    value, and use (strcat path ".dwg"), then save there .??
     
    Thomas Smith, Jan 27, 2004
    #6
  7. DWGVAR attaches xdata to layer "0"

     
    Allen Johnson, Jan 27, 2004
    #7
  8. chrisb

    chrisb Guest

    I know about DWGPREFIX, and it won't help me here - it's a situation where, in essence, I need TWO DWGPREFIX's - one for one save destination, the other for the alternate save destination.
     
    chrisb, Jan 27, 2004
    #8
  9. chrisb

    chrisb Guest

    Thanks to all who responded - there are some good ideas here, and I'll probably use one, two, or maybe a combination of more than one of them. This confirms my understanding that there is no simple, predefined AutoLisp variable for such cases - a little surprising, but, if I have to go about it in a sort of roundabout, Rube Goldberg-ish way, (using an external file, or a text file), I guess it's no big deal. Just maybe a little fragile- text file gets lost, accidentally deleted - same thing with the attribute idea -layer gets inadvertently frozen, or some other contingency along those lines - but, hey - it's only AutoLISP, not Turbo C ++ (which I have no clue about, other than it's existence, and that it's a `serious' programming language). So thanks, colleagues, your input is very much appreciated.
    -Chris
     
    chrisb, Jan 27, 2004
    #9
  10. chrisb

    Jeff Mishler Guest

    " Just maybe a little fragile- text file gets lost, accidentally deleted -
    same thing with the attribute idea -layer gets inadvertently frozen, or
    some other contingency along those lines - but, hey - it's only AutoLISP,"

    This is why you'd want to use Xdata or Xrecords and attach it to something
    in the drawing database that can't be renamed, purged, deleted, etc.

    Things to use are Layer "0", any table (block, style, layer), etc.

    You can name an Xrecord dictionary holding the data anything you want so
    other add-ins won't affect it and snoopy users will usually just shrug thier
    shoulders...... an example name could be
    "Super_Secret_Alternate_Path_for_Saved_ Files"

    Search for a lisp file that has a ton of functions in it for creating &
    manipulating Dictionaries. I found it in this group last year and it is
    extremely helpful.

    Jeff
     
    Jeff Mishler, Jan 27, 2004
    #10
  11. chrisb

    What about using the "TEMPREFIX" sysvar for automatic backup to temp
    directory? (read only), or the "MYDOCUMENTSPREFIX" sysvar?

    Not sure what your trying to do exactly...
    --
    Phil Kenewell
    ----------------------
    Gage Designer
    North American Lighting, Inc.

    probably use one, two, or maybe a combination of more than one of them. This
    confirms my understanding that there is no simple, predefined AutoLisp
    variable for such cases - a little surprising, but, if I have to go about it
    in a sort of roundabout, Rube Goldberg-ish way, (using an external file, or
    a text file), I guess it's no big deal. Just maybe a little fragile- text
    file gets lost, accidentally deleted - same thing with the attribute
    dea -layer gets inadvertently frozen, or some other contingency along those
    lines - but, hey - it's only AutoLISP, not Turbo C ++ (which I have no clue
    about, other than it's existence, and that it's a `serious' programming
    language). So thanks, colleagues, your input is very much appreciated.
     
    Phil Kenewell, Jan 27, 2004
    #11
  12. Here's another one

    SAVEFILEPATH sysvar - Reads and sets the location of Automatic save files.
     
    Phil Kenewell, Jan 27, 2004
    #12
  13. chrisb

    dean_bourke Guest

    If you want you backup dwgs spread over multilpe folders, then this suggestion will not do, but you could just duplicate your first directory structure to a second drive (even substed a drive) by stripping off the drive letter from the full path and substituting the new driver letter for your second dwg copy (or third or fourth...)
     
    dean_bourke, Jan 27, 2004
    #13
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.