Hi,
I would like to create an asset which behaves differently if it's created in OBJ context and in SOP context.
The kwargs dict apparently doesn't include information about from which context the tool called, so my question is what is the preffered way to get this information.
I would also like to ask where can I find detailed documentation on scripting assets, and the supporting Python modules like “toolutils” and such.
Thanks in advance
Mate
Getting context information from a tool script
8833 2 0- gadfly16
- Member
- 65 posts
- Joined: May 2009
- Offline
- rafal
- Staff
- 1449 posts
- Joined: July 2005
- Offline
The tool may be invoked from the shelf, which does not have a context. But, there is a kward that tells you which pane the tool was invoked from (and it is None for shelf). From there you can get the pane object, from the pane object its path, and from the path the network object, and from the network object the context type.
You can look inside the toolutils.py on how genericTool() does it, but the general idea is:
context_type = kwargs.pwd().childTypeCategory()
As I hinted above, to get info about ‘toolutils’ module, look for comments inside toolutils.py, etc.
and, about scripting assets:
http://www.sidefx.com/index.php?option=com_content&task=view&id=966&Itemid=132 [sidefx.com]
You can look inside the toolutils.py on how genericTool() does it, but the general idea is:
context_type = kwargs.pwd().childTypeCategory()
As I hinted above, to get info about ‘toolutils’ module, look for comments inside toolutils.py, etc.
and, about scripting assets:
http://www.sidefx.com/index.php?option=com_content&task=view&id=966&Itemid=132 [sidefx.com]
- gadfly16
- Member
- 65 posts
- Joined: May 2009
- Offline
-
- Quick Links