-
Notifications
You must be signed in to change notification settings - Fork 4
/
PARMmenu.xml
264 lines (226 loc) · 9.29 KB
/
PARMmenu.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?xml version="1.0" encoding="UTF-8"?>
<menuDocument>
<menu>
<addScriptItem id="h.pane.parms.hammer_select">
<label>Select...</label>
<parent>root_menu</parent>
<insertBefore />
<context>
<expression>
from hammer_tools.settings import SettingsManager
if not SettingsManager.instance().value('hammer.select_parm_value.select.enable'):
return 0
parm = kwargs['parms'][0]
template = parm.parmTemplate()
try:
items = parm.menuItems()
except hou.OperationFailed:
return 0
if template.type() in (hou.parmTemplateType.Int,
hou.parmTemplateType.String,
hou.parmTemplateType.Menu) and \
len(items) > 3:
return 1
return 0
</expression>
</context>
<scriptCode>
from hammer_tools.quick_selection import selectAny
parm = kwargs['parms'][0]
selectAny(parm)
</scriptCode>
</addScriptItem>
<addScriptItem id="h.pane.parms.hammer_select_font">
<label>Select Font...</label>
<parent>root_menu</parent>
<insertBefore />
<context>
<networkCategory>Sop,Cop2</networkCategory>
<expression>
from hammer_tools.settings import SettingsManager
if not SettingsManager.instance().value('hammer.select_parm_value.select_font.enable'):
return 0
parm = kwargs['parms'][0]
if parm.name().lower() == 'font' or \
parm.description().lower() == 'font':
return 1
return 0
</expression>
</context>
<scriptCode>
from hammer_tools.quick_selection import selectFont
parm = kwargs['parms'][0]
selectFont(parm)
</scriptCode>
</addScriptItem>
<addScriptItem id="h.pane.parms.hammer_open_location">
<label>Open Location...</label>
<parent>root_menu</parent>
<insertBefore />
<context>
<expression>
from hammer_tools.settings import SettingsManager
settings = SettingsManager.instance()
if not settings.value('hammer.open_location.enable'):
return 0
parm = kwargs['parms'][0]
template = parm.parmTemplate()
if template.type() == hou.parmTemplateType.String and \
template.stringType() == hou.stringParmType.FileReference and \
parm.name().lower() != 'font' and parm.description().lower() != 'font':
return 1
return 0
</expression>
</context>
<scriptCode>
from hammer_tools.parmutils import openLocationFromParm
parm = kwargs['parms'][0]
openLocationFromParm(parm)
</scriptCode>
</addScriptItem>
<addScriptItem id="h.pane.parms.hammer_choose_file_or_folder">
<labelExpression>
temp = 'Choose {} with Native Dialog...'
parm = kwargs['parms'][0]
template = parm.parmTemplate()
if template.dataType() == hou.parmData.String and \
template.fileType() == hou.fileType.Directory:
return temp.format('Folder')
else:
return temp.format('File')
</labelExpression>
<parent>root_menu</parent>
<insertBefore>h.pane.parms.hammer_open_location</insertBefore>
<context>
<expression>
parm = kwargs['parms'][0]
template = parm.parmTemplate()
if template.type() == hou.parmTemplateType.String and \
template.stringType() == hou.stringParmType.FileReference and \
parm.name().lower() != 'font' and parm.description().lower() != 'font':
return 1
return 0
</expression>
</context>
<scriptCode>
import hammer_tools.parmutils as pu
reload(pu)
parm = kwargs['parms'][0]
pu.chooseFileAndSetParm(parm)
</scriptCode>
</addScriptItem>
<subMenu id="h.pane.parms.hammer_set_ramp_interpolation">
<label>Set Interpolation</label>
<parent>root_menu</parent>
<insertBefore />
<context>
<expression>
from hammer_tools.settings import SettingsManager
if not SettingsManager.instance().value('hammer.set_interpolation.enable'):
return 0
parm = kwargs['parms'][0]
template = parm.parmTemplate()
if template.type() == hou.parmTemplateType.Ramp and \
parm.node().parent().isEditable():
return 1
return 0
</expression>
</context>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_constant">
<label>Constant</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.Constant)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_linear">
<label>Linear</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.Linear)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_catmullrom">
<label>Catmull-Rom</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.CatmullRom)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_monotonecubic">
<label>Monotone Cubic</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.MonotoneCubic)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_bezier">
<label>Bezier</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.Bezier)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_bspline">
<label>B-Spline</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.BSpline)
</scriptCode>
</scriptItem>
<scriptItem id="h.pane.parms.hammer_set_ramp_interpolation_hermite">
<label>Hermite</label>
<scriptCode>
from hammer_tools.parmutils import setRampParmInterpolation
parm = kwargs['parms'][0]
setRampParmInterpolation(parm, hou.rampBasis.Hermite)
</scriptCode>
</scriptItem>
</subMenu>
<addScriptItem id="h.pane.parms.hammer_toggle_expression">
<labelExpression>
from hammer_tools.parmutils import isExpressionDisabled
parm = kwargs['parms'][0]
try:
parm.expression()
has_expression = True
except hou.OperationFailed:
has_expression = False
if has_expression:
return 'Disable Expression'
if isExpressionDisabled(parm):
return 'Enable Expression'
return ''
</labelExpression>
<parent>expression_menu</parent>
<insertAfter>toggle_expr</insertAfter>
<context>
<expression>
from hammer_tools.parmutils import isExpressionDisabled
parm = kwargs['parms'][0]
try:
parm.expression()
has_expression = True
except hou.OperationFailed:
has_expression = False
if has_expression:
return True
if isExpressionDisabled(parm):
return True
return False
</expression>
</context>
<scriptCode>
from hammer_tools.parmutils import toggleExpression
parm = kwargs['parms'][0]
toggleExpression(parm)
</scriptCode>
</addScriptItem>
</menu>
</menuDocument>