Hey all, I'm making a shelf tool that loads an external .ui file using the QUiLoader class from PySide2. My issue at the moment is determining where I need to place this .ui file so I can reference it relatively when loading it within the script.
Does anyone know what directory location shelf tools are executed from?
Thanks!
Python Shelf Tool executable location
4391 10 1- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
- Enivob
- Member
- 2625 posts
- Joined: June 2008
- Offline
Check out the docs…
http://www.sidefx.com/docs/houdini/hom/locations.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/tool_script.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/locations.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/tool_script.html [www.sidefx.com]
Edited by Enivob - Nov. 21, 2017 15:20:09
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
Enivob
Check out the docs…
http://www.sidefx.com/docs/houdini/hom/locations.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/tool_script.html [www.sidefx.com]
I've read both of these sources, so either I'm not quite seeing where it explains this, or the documentation doesn't elaborate on where shelf tools execute from on the file system.
- Enivob
- Member
- 2625 posts
- Joined: June 2008
- Offline
You could look into executing an Hscript command inside of python to fetch one of the convenient global variables, like $HOME.
https://www.sidefx.com/docs/houdini/hom/hou/hscript.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/hou/hscriptExpression.html [www.sidefx.com]
https://www.sidefx.com/docs/houdini/hom/hou/hscript.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/hou/hscriptExpression.html [www.sidefx.com]
Edited by Enivob - Nov. 21, 2017 18:04:53
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- anon_user_00157425
- Member
- 45 posts
- Joined: Feb. 2014
- Offline
- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
Enivob
You could look into executing an Hscript command inside of python to fetch one of the convenient global variables, like $HOME.
https://www.sidefx.com/docs/houdini/hom/hou/hscript.html [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/hou/hscriptExpression.html [www.sidefx.com]
Looks like it defaults to executing from $HOME. This is inconvenient because $HOME could be in a completely different location than where the shelf tool definition is being stored. I am distributing the shelf tool in a collection of files that get added to HOUDINI_PATH. I want to be able to package the .ui file alongside that and have everything work in terms of relative paths. Any solutions for this?
- anon_user_00157425
- Member
- 45 posts
- Joined: Feb. 2014
- Offline
- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
- Matthew Bennett
- Member
- 1 posts
- Joined: Nov. 2013
- Offline
- sashaouellet
- Member
- 14 posts
- Joined: May 2017
- Offline
Matthew Bennett
I am resurrecting this topic as I don't quite understand.
If I have a file C:\Users\foo\Desktop\python_script_I_want_to_execute_when_I_push_my_shelf_tool.py
What is required to input into my shelf tool script in order to have it execute that file?
Any info would be much appreciated.
Are you seeking to import that module? If so, “C:\Users\foo\Desktop” needs to be in PYTHONPATH (set in houdini.env), and you'd import the module like normal in your shelf script i.e.:
import python_script_I_want_to_execute_when_I_push_my_shelf_tool
Obviously, you'd package a directory with all your scripts alongside your shelf tool.
-
- Quick Links