TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: uncoolperson on January 25, 2006, 04:19:48 PM
-
so for some reason our drafters have issues with saving, really... and it doesn't get caught in time to use the back up files
so here's what i'm trying, the problem is that it keeps saving the backup of the file being closed with the filename of the drawing being opened...sometimes
(vlr-remove-all :VLR-DWG-REACTOR)
(VLR-DWG-REACTOR
nil
'((:VLR-BEGINCLOSE . saveacopy))
)
(DEFUN saveacopy (something somethingelse)
(IF (NOT
(SETQ opened (OPEN (SETQ tempname (STRCAT (GETVAR "SAVEFILEPATH")
(MENUCMD
"M=$(edtime,$(getvar,date),mon-dd-yyyy-h-mmam/pm)"
)
"-"
(GETVAR "DWGname")
)
)
"r"
)
)
)
(VLA-SENDCOMMAND
(VLAX-GET (VLAX-GET-ACAD-OBJECT) "activedocument")
(STRCAT "filedia " "0 " ".save\r" tempname "\r" "filedia " "1 ")
)
(CLOSE opened)
)
)
any ideas
again i appologize this isn't the prettiest code...
-
so for some reason our drafters have issues with saving, really... and it doesn't get caught in time to use the back up files
so here's what i'm trying, the problem is that it keeps saving the backup of the file being closed with the filename of the drawing being opened...sometimes
(vlr-remove-all :VLR-DWG-REACTOR)
(VLR-DWG-REACTOR
nil
'((:VLR-BEGINCLOSE . saveacopy))
)
(DEFUN saveacopy (something somethingelse)
(IF (NOT
(SETQ opened (OPEN (SETQ tempname (STRCAT (GETVAR "SAVEFILEPATH")
(MENUCMD
"M=$(edtime,$(getvar,date),mon-dd-yyyy-h-mmam/pm)"
)
"-"
(GETVAR "DWGname")
)
)
"r"
)
)
)
(VLA-SENDCOMMAND
(VLAX-GET (VLAX-GET-ACAD-OBJECT) "activedocument")
(STRCAT "filedia " "0 " ".save\r" tempname "\r" "filedia " "1 ")
)
(CLOSE opened)
)
)
any ideas
again i appologize this isn't the prettiest code...
a couple of things ;
(vlr-remove-all :VLR-DWG-REACTOR) ....
What happens if there are other DWG-REACTOR's set in the drawing by other applications ?
(MENUCMD "M=$(edtime,$(getvar,date),mon-dd-yyyy-h-mmam/pm)" )
This may be better as yyyy-mm-dd...etc for file sorting.
-
(vlr-remove-all :VLR-DWG-REACTOR) ....
What happens if there are other DWG-REACTOR's set in the drawing by other applications ?
thanks, i really don't know why i didn't think of that... thanks for that catch kerry.
-
so i went diging in the vlisp stuff (wow!) i'm still trying to figure all this mess out.. there's probably an easier way then 4 vlax-get's but by replacing
(GETVAR "DWGname")
with this
(STRCAT (VL-FILENAME-BASE
(VLAX-GET (VLAX-GET (VLAX-GET (VLAX-GET (VLAX-GET-ACAD-OBJECT) "activedocument")
"views"
)
"document"
)
"fullname"
)
)
".dwg"
)
things seem to work better.... any better ideas?
-
you may also want to set your Autosave to something smaller like 4 minutes as well...
Pieter
-
so i went diging in the vlisp stuff (wow!) i'm still trying to figure all this mess out.. there's probably an easier way then 4 vlax-get's but by replacing
(GETVAR "DWGname")
with this
(STRCAT (VL-FILENAME-BASE
(VLAX-GET (VLAX-GET (VLAX-GET (VLAX-GET (VLAX-GET-ACAD-OBJECT) "activedocument")
"views"
)
"document"
)
"fullname"
)
)
".dwg"
)
things seem to work better.... any better ideas?
could be shortened to:
(strcat (vl-filename-base
(vla-get-fullname
(vla-get-activedocument (vlax-get-acad-object))
)
)
".dwg"
)
-
could be shortened to: ...
Thanks... that sure is prettier
you may also want to set your Autosave to something smaller like 4 minutes as well...
the reason for this is the drafters here have found so many different ways to screw a drawing up beyond anything autosave could fix... and so far have been able to screw things up so that this is only going to help about 1/3 of the time!