Is there a way what I run python scripts when a custom ROP OTL is running (rendering)?
I have tried to create a button which has a callback script and the button links to the render button( which is gray out in the type properties ), so the callback script runs when the render button is pushed. However, if I run a Hscript “render” on that custom ROP, this will just execute the render operation and has no effect on my button, which means no callback script runs as I expect.
basically, what I want is something like python type OTL ROP. and can be executed by Hscript “render” command.
Run python scripts in a Custom ROP OTL
8016 6 1- laiwayne
- Member
- 58 posts
- Joined: Sept. 2009
- Offline
- edward
- Member
- 7715 posts
- Joined: July 2005
- Offline
- laiwayne
- Member
- 58 posts
- Joined: Sept. 2009
- Offline
edward
Why not just use the pre-render script parm?
Pre-render script requires a ROP as a base which I want that is my ROP OTL. I do not want to add the script in a Mantra ROP or Geometry ROP because I do not need to render out any image or bgeo. All I need is get the values from the OTL parm and pass it to my script.
- edward
- Member
- 7715 posts
- Joined: July 2005
- Offline
- laiwayne
- Member
- 58 posts
- Joined: Sept. 2009
- Offline
- dulo
- Member
- 383 posts
- Joined: June 2010
- Offline
- sburrichter
- Member
- 23 posts
- Joined: April 2013
- Offline
Okay. This was driving me crazy and this thread kept popping up. Here's the solution I found.
Version: H15.5.480
Scenerio: Created a new Output Driver via the New Operator Type prompt. Need to attach the “Render to Disk” button to a python script, but the callback script option is disabled.
Solution:
1. Open up the type properties pane
2. Add a file parameter with the name “soho_program”
3. Assuming you have a PythonModule setup in the scripts section, type “opdef:.?PythonModule” into the field
4. Add a file parameter with the name “soho_outputmode”
5. Type “2” into the field
Now that “Render to Disk” button will run the PythonModule defined in the scripts tab. “soho_program” defines the python script that'll run. Output mode 2 will prevent anything special happening on stdout.
I still need to test it more, but I typed this up as soon as I got a print statement through.
Edit: If you need to pass in the current node, you can use hou.pwd() to get the current node. Essentially that operator is your current working directory.
Recommended reading: SOHO [sidefx.com], opdef: [sidefx.com]
Version: H15.5.480
Scenerio: Created a new Output Driver via the New Operator Type prompt. Need to attach the “Render to Disk” button to a python script, but the callback script option is disabled.
Solution:
1. Open up the type properties pane
2. Add a file parameter with the name “soho_program”
3. Assuming you have a PythonModule setup in the scripts section, type “opdef:.?PythonModule” into the field
4. Add a file parameter with the name “soho_outputmode”
5. Type “2” into the field
Now that “Render to Disk” button will run the PythonModule defined in the scripts tab. “soho_program” defines the python script that'll run. Output mode 2 will prevent anything special happening on stdout.
I still need to test it more, but I typed this up as soon as I got a print statement through.
Edit: If you need to pass in the current node, you can use hou.pwd() to get the current node. Essentially that operator is your current working directory.
Recommended reading: SOHO [sidefx.com], opdef: [sidefx.com]
Edited by sburrichter - Oct. 21, 2016 14:16:34
-
- Quick Links