Shelf Tools - Script per tool

   1024   2   1
User Avatar
Member
337 posts
Joined: June 2013
Online
Hi
I see the script portion of a shelf tool is included in the shelf tab file with all others tools and tool data.
I want to have the script portion to be outsourced to a file per tool, so that I can focus on the code per tool in an external IDE and have a repository that I can sync across locations.

What's the common way to this? Any example?
In XSI I would in the tool dialog just point to a .py file.

So far I'm doing this:
- Create a folder in any of the python2.7libs folders be it HOME or HSITE. For example, PRB_HOM folder with a file obj_material_split.py, which contains a function wrapping what I want to execute, for example in this case, main().
- In the shelf tool Script tab have something like:
from PRB_HOM import obj_material_split
obj_material_split.main()

Thanks
Edited by probiner - April 1, 2019 18:42:35
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
You can put your python stuff in $USER_PREFS/python2.7libs/yourcoolpythonstuff.py
def greeting(name):
  print("Hello, " + name)
and then just use import in your tools script section:
import mytoolstuff

yourcoolpythonstuff.greeting("Bonsak")
Edited by bonsak - April 1, 2019 09:28:23
http://www.racecar.no [www.racecar.no]
User Avatar
Member
337 posts
Joined: June 2013
Online
Thanks @bonsak
I had updated the initial message without refreshing the browser!

The folder bit was important for repository purposes.

Cheers
Edited by probiner - April 1, 2019 10:06:14
  • Quick Links