-
Notifications
You must be signed in to change notification settings - Fork 196
/
ShelfToolMenu.xml
123 lines (110 loc) · 3.7 KB
/
ShelfToolMenu.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file defines the entries in the menu that appears on a mouse
right-button click over a shelf tool in Houdini's shelving area.
For scriptItem elements, a 'kwargs' python dictionary is provided with the
flolowing values:
'ownername' : The name of the tool that popped up the menu.
'ownerparentname' : The name of the shelf that contains the tool.
plus the standard script menu item kwargs:
'toolname' : The menu item's hotkey id
(ie. the element's id prefixed with h.shelf.menu.)
'altclick' : True if the Alt key was also pressed, False otherwise
'ctrlclick' : True if the Ctrl key was also pressed, False otherwise
'shiftclick': True if the Shift key was also pressed, False otherwise
'cmdclick' : True if the Option key was also pressed, False
otherwise. Note that this can only be true on OSX.
For the <context> block, the <ownerMask> refers to the name of the shelf,
and the <expression> is given kwargs similar to the script item.
For example:
<scriptItem id="my_action">
<label>My Action</label>
<scriptCode><![CDATA[
arguments = '\n '.join(['%s = %s' % (k,w) for (k,w) in kwargs.items()])
hou.ui.displayMessage('My Action with kwargs:\n ' + arguments)
]]></scriptCode>
</scriptItem>
<scriptItem id="my_box_action">
<label>My Box Action</label>
<context>
<ownerMask>*box*</ownerMask>
</context>
<scriptCode>hou.ui.displayMessage('Test')</scriptCode>
</scriptItem>
<scriptItem id="my_another_box_action">
<label>My Another Box Action</label>
<context>
<expression>kwargs.get('ownername','') == 'sop_box'</expression>
</context>
<scriptCode>hou.ui.displayMessage('Test')</scriptCode>
</scriptItem>
<scriptItem id="my_another_box_action">
<label>My Contrived Example</label>
<context>
<expression>__import__('time').time() % 2</expression>
</context>
<scriptCode>hou.ui.displayMessage('Test')</scriptCode>
</scriptItem>
<menuDocument>
<modifyItem id="edit_tool">
<labelExpression>kwargs.get('ownername','')</labelExpression>
</modifyItem>
</menuDocument>
-->
<menuDocument>
<menu>
<scriptItem id="expreditor_edit_shelf_tool">
<label>Edit in external editor...</label>
<insertAtIndex>2</insertAtIndex>
<context>
<expression>
<![CDATA[
try:
from HoudiniExprEditor import ParmWatcher
return True
except:
return False]]>
</expression>
</context>
<scriptCode>
<![CDATA[
from HoudiniExprEditor import ParmWatcher
try:
reload(ParmWatcher)
except NameError:
from importlib import reload
reload(ParmWatcher)
tool = hou.shelves.tool(kwargs["ownername"])
if tool:
ParmWatcher.add_watcher(tool, type_="__shelf_tool|" + str(tool.language()).split('.')[-1].lower())]]>
</scriptCode>
</scriptItem>
<scriptItem id="expreditor_remove_watcher_shelf_tool">
<label>Remove file watcher</label>
<context>
<expression>
<![CDATA[
try:
from HoudiniExprEditor import ParmWatcher
tool = hou.shelves.tool(kwargs["ownername"])
if tool:
return ParmWatcher.tool_has_watcher(tool, type_="__shelf_tool|" + str(tool.language()).split('.')[-1].lower())
except:
return False]]>
</expression>
</context>
<scriptCode>
<![CDATA[
from HoudiniExprEditor import ParmWatcher
try:
reload(ParmWatcher)
except NameError:
from importlib import reload
reload(ParmWatcher)
tool = hou.shelves.tool(kwargs["ownername"])
if tool:
ParmWatcher.remove_file_watched(tool, type_="__shelf_tool|" + str(tool.language()).split('.')[-1].lower())]]>
</scriptCode>
</scriptItem>
</menu>
</menuDocument>