1 from pathlib import Path
2 import hou
3 import json
4
5 # This file runs when a .hip file is loaded
6
7 current_file = hou.hipFile.path()
8 state_file = Path(hou.getenv("HOUDINI_USER_PREF_DIR")) / "st_data" / "state.json"
9 data = {"last_opened_file": current_file}
10
11 # Write to JSON
12 updates = {"last_file": current_file}
13 with open(state_file, 'w') as f:
14 json.dump(updates, f, indent=4)