-
Notifications
You must be signed in to change notification settings - Fork 195
/
PARMmenu.xml
184 lines (171 loc) · 4.6 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
-->
<menuDocument>
<!-- menuDocument can only contain 1 menu element, whose id is
implicitly "root_menu"
-->
<menu>
<scriptItem id="samplescreencolor">
<label>Sample Screen Colors</label>
<context>
<expression>
<![CDATA[
if len(kwargs["parms"]) == 0:
return False
parm = kwargs["parms"][0]
return parm.parmTemplate().type() == hou.parmTemplateType.Ramp]]>
</expression>
</context>
<scriptCode>
<![CDATA[
from labsopui import screensampling
try:
reload(screensampling)
except NameError:
from importlib import reload
reload(screensampling)
screensampling.sample_ramp_color(kwargs["parms"])
]]>
</scriptCode>
</scriptItem>
<scriptItem id="show_in_file_browser">
<label>Show in File Browser</label>
<insertAtIndex>20</insertAtIndex>
<context>
<expression>
<![CDATA[
import os
if len(kwargs["parms"]) == 0:
return False
parm = kwargs["parms"][0]
if parm.parmTemplate().type() == hou.parmTemplateType.String:
path = hou.text.expandString(parm.evalAsString())
return os.path.isfile(path) or os.path.isdir(os.path.dirname(path))
return False]]>
</expression>
</context>
<scriptCode>
<![CDATA[
import os
parm = kwargs["parms"][0]
path = hou.text.expandString(parm.evalAsString())
if os.path.isfile(path):
hou.ui.showInFileBrowser(path)
elif os.path.isdir(os.path.dirname(path)):
hou.ui.showInFileBrowser(os.path.dirname(path)+"/")
]]>
</scriptCode>
</scriptItem>
<!-- External Editor -->
<addScriptItem id="open_external_editor">
<label>Edit in External Editor</label>
<parent>expression_menu</parent>
<!-- <insertAfter>edit_expression</insertAfter>-->
<context>
<expression>
<![CDATA[
try:
from HoudiniExprEditor import ParmWatcher
return ParmWatcher.is_valid_parm(kwargs["parms"][0])
except:
return False]]>
</expression>
</context>
<scriptCode>
<![CDATA[
from HoudiniExprEditor import ParmWatcher
try:
reload(ParmWatcher)
except NameError:
from importlib import reload
reload(ParmWatcher)
ParmWatcher.add_watcher(kwargs["parms"][0])]]>
</scriptCode>
</addScriptItem>
<!-- Remove watcher -->
<addScriptItem id="remove_file_watcher">
<label>Remove File Watcher</label>
<parent>expression_menu</parent>
<!-- <insertAfter>open_external_editor</insertAfter>-->
<context>
<expression>
<![CDATA[
try:
from HoudiniExprEditor import ParmWatcher
return ParmWatcher.parm_has_watcher(kwargs["parms"][0])
except:
return False]]>
</expression>
</context>
<scriptCode>
<![CDATA[
from HoudiniExprEditor import ParmWatcher
try:
reload(ParmWatcher)
except NameError:
from importlib import reload
reload(ParmWatcher)
ParmWatcher.remove_file_watched(kwargs["parms"][0])]]>
</scriptCode>
</addScriptItem>
<subMenu id="expression_menu">
<label>Expression</label>
<scriptItem id="set_wedgeindex">
<label>Set to Wedge Index</label>
<insertAfter>use_old_language</insertAfter>
<context>
<expression>
if len(kwargs["parms"]) == 0:
return False
import hou
from labsopui import wedge_tools
return wedge_tools.canSetWedgeIndex(kwargs["parms"][0])
</expression>
</context>
<scriptCode>
<![CDATA[
import hou
from labsopui import wedge_tools
wedge_tools.setWedgeIndex(kwargs["parms"])
]]>
</scriptCode>
</scriptItem>
<scriptItem id="wedge_value">
<label>Wedge Value...</label>
<insertAfter>set_wedgeindex</insertAfter>
<context>
<expression>
if len(kwargs["parms"]) == 0:
return False
import hou
from labsopui import wedge_tools
return wedge_tools.canWedgeValue(kwargs["parms"][0])
</expression>
</context>
<scriptCode>
<![CDATA[
import hou
from labsopui import wedge_tools
wedge_tools.wedge(kwargs["parms"])
]]>
</scriptCode>
</scriptItem>
<scriptItem id="ftrimify">
<label>Trim Excess Fractional Digits</label>
<insertAfter>wedge_value</insertAfter>
<context>
<expression>
if len(kwargs["parms"]) == 0:
return False
return isinstance(kwargs["parms"][0].parmTemplate(), hou.StringParmTemplate)
</expression>
</context>
<scriptCode><![CDATA[
from labsopui import ftrimify
ftrimify.ftrimify(kwargs["parms"][0])
]]></scriptCode>
</scriptItem>
</subMenu>
</menu>
</menuDocument>