Saving avariable to a dwg file

chrisb

Usenet Archive
Joined
Jul 24, 2003
Messages
16
Reaction score
0
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
 
See system variable "DWGPREFIX".
e.g.
(setq Path (getvar "dwgprefix"))

Bob
 
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) )
)

chrisb said:
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.
 
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.
 
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
 
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.

ECCAD said:
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 .??
 
DWGVAR attaches xdata to layer "0"

Thomas Smith said:
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 .??
 
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.
 
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
 
" 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
 
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...
chrisb said:
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 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.
 
Here's another one

SAVEFILEPATH sysvar - Reads and sets the location of Automatic save files.
 
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...)
 

Latest threads

Back
Top