MrScienceOfficer Posted December 8, 2015 Share Posted December 8, 2015 (edited) EDIT : I figured I would change the title so it will be possible to find this later... .......................................................................................................................... Yea... Whats up with that? I thought 123.py is supposed to run every time one launches Houdini, but it only runs when I launch Houdini into an empty file). I.e. C:\Program Files\Side Effects Software\Houdini 15.0.298\bin\houdinifx.exe without command args runs 123.py but with say I run it with $HIP\pythonToolsTesting.hip as a command arg it doesn't run 123.py. Is that right? If so how can I append a path to look for a python module then? ....EDIT: Okay Nevermind So just use 456.py right? Edited December 10, 2015 by MrScienceOfficer Quote Link to comment Share on other sites More sharing options...
fathom Posted December 8, 2015 Share Posted December 8, 2015 123.py runs on empty, 456.py runs when you load with a script or load a new script into houdini. i'd love to see a 789.py run when you save... altho, really these should all be handled via some kind of event system. houdini 16 maybe? Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted December 8, 2015 Author Share Posted December 8, 2015 With the HDK you can register a callback for save events, it's actually pretty easy... shouldn't theoretically be too difficult to tie into a python callback. What kind of things would you save through python, out of curiosity? Quote Link to comment Share on other sites More sharing options...
fathom Posted December 9, 2015 Share Posted December 9, 2015 the goal would be to learn when somebody has saved out a file with a potentially new name and then adjust internal env variables to reflect the change (pipeline stuff, basically). Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted December 9, 2015 Author Share Posted December 9, 2015 That makes sense, I doubt it's possible to get the name of the file though, that would require a bit of hackery. Would be really interesting to see if its possible to set up a save event callback using inlinecpp. Quote Link to comment Share on other sites More sharing options...
fathom Posted December 10, 2015 Share Posted December 10, 2015 you can get the current hipfile name via python calls, so that's not an issue. the only problem is knowing when you need to do that. you can kind of hack together something by hooking into other events that fire more frequently, then checking the hipfile name to see if it's changed every time. but that kind of stuff makes me feel dirty. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted December 10, 2015 Author Share Posted December 10, 2015 (edited) That is really dirty, I'd almost say it's filthy... I got it to work #include <UT/UT_DSOVersion.h> #include <CMD/CMD_Args.h> #include <CMD/CMD_Manager.h> #include <OP/OP_Director.h> static OP_ERROR mySaveCall(std::ostream&, void* save) { const char* pythonfile = "C:/.../789.py"; OPgetDirector()->runPython(CMDgetManager(), pythonfile); return OP_ERROR::UT_ERROR_NONE; } static void cmd_args(CMD_Args &args) { OPgetDirector()->setSaveCallback(mySaveCall, NULL); } void CMDextendLibrary(CMD_Manager *cman) { cman->installCommand("installMySaveHook", "", cmd_args); } All you need to do is run installMySaveHook from 456.cmd Edited December 10, 2015 by MrScienceOfficer 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.