I took this from archeye's posts from a long time ago, and his work on machinekit and made it usercommand-able
Axis loads the most recent file opened on startup, so what ever you closed with, it opens with.
Add one of these to your usercommand file or axisrc and under [DISPLAY] in ini, add
LOAD_LASTFILE = YES
Code:
##########################################################
######## LOAS_LAST FILE PY2 for 2.8 ##########
######## In ini file under [DISPLAY] ##################
######## LOAD_LASTFILE = YES ################
##########################################################
loadlast = inifile.find('USER_COMMANDS', 'LOAD_LASTFILE')
if loadlast == "YES" :
load_lastfile = True
else:
load_lastfile = False
lastfile = ""
recent = ap.getpref('recentfiles', [], repr)
if len(recent):
lastfile = recent.pop(0)
code = []
addrecent = True
if args:
initialfile = args[0]
elif os.environ.has_key("AXIS_OPEN_FILE"):
initialfile = os.environ["AXIS_OPEN_FILE"]
elif inifile.find("DISPLAY", "OPEN_FILE"):
initialfile = inifile.find("DISPLAY", "OPEN_FILE")
elif os.path.exists(lastfile) and load_lastfile:
initialfile = lastfile
print "Loading "
print initialfile
elif lathe:
initialfile = os.path.join(BASE, "share", "axis", "images","axis-lathe.ngc")
addrecent = False
else:
initialfile = os.path.join(BASE, "share", "axis", "images", "axis.ngc")
addrecent = False
if os.path.exists(initialfile):
open_file_guts(initialfile, False, addrecent)
Code:
##########################################################
######## LOAS_LAST FILE PY3 for 2.9 ############
######## In ini file under [DISPLAY] ##################
######## LOAD_LASTFILE = YES ################
##########################################################
loadlast = inifile.find('DISPLAY', 'LOAD_LASTFILE')
if loadlast == "YES" :
load_lastfile = True
else:
load_lastfile = False
lastfile = ""
recent = ap.getpref('recentfiles', [], repr)
if len(recent):
lastfile = recent.pop(0)
code = []
addrecent = True
if args:
initialfile = args[0]
elif "AXIS_OPEN_FILE" in os.environ:
initialfile = os.environ["AXIS_OPEN_FILE"]
elif inifile.find("DISPLAY", "OPEN_FILE"):
initialfile = inifile.find("DISPLAY", "OPEN_FILE")
elif os.path.exists(lastfile) and load_lastfile:
initialfile = lastfile
print ("Loading ")
print (initialfile)
elif lathe:
initialfile = os.path.join(BASE, "share", "axis", "images","axis-lathe.ngc")
addrecent = False
else:
initialfile = os.path.join(BASE, "share", "axis", "images", "axis.ngc")
addrecent = False
if os.path.exists(initialfile):
open_file_guts(initialfile, False, addrecent)