Search - User list
Full Version: Autosave 456.py
Root » Houdini Lounge » Autosave 456.py
chrisangelius
Hi guys,

Trying to get this python script I came across to work in H17.

# Ask about turning on Autosave
# but only if running interactive Houdini session!

set fullver = `run(“version -n”)`
set app = `arg($fullver,0)`

if(`strcmp($app,“hscript”)` < 0 && `strcmp($app,“rscript”)` < 0 && `strcmp($app,“hbatch”)` < 0)
set turnOn = `run(“message -b Yes,No -d 0 Turn on Autosave?”)`

if($turnOn == 0)
autosave on
endif
endif


Console is giving me a syntax error on startup.
Error running Python code:
SyntaxError: ('invalid syntax', ('DUsers/Chris Angelius/Documents/houdini17.0/scripts/456.py', 4, 11, ‘set fullver = `run(\x93version -n\x94)`\n’))
chrisangelius
It's been pointed out that the above snippet is actually hscript and not python but even changing the script to a .cmd file which should allow hscript to be run at launch doesn't actually work.

I'm now using
import hou
hou.appendSessionModuleSource('''hou.hscript("autosave on")''')

which defaults autosave to on but would prefer to have the option of enabling it via a popup dialogue at the start of each session.

If anyone has any idea how to code that it would be appreciated.
Stalkerx777
$HOME/scripts/456.py
if hou.isUIAvailable():
import hdefereval
def _ask():
if hou.ui.displayMessage("Turn on autosave? ", buttons=("No", "Yes")) == 1:
hou.hscript("autosave on")
else:
hou.hscript("autosave off")
hdefereval.execute_deferred(_ask)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB