-
Notifications
You must be signed in to change notification settings - Fork 0
/
OPmenu.xml
79 lines (76 loc) · 3.19 KB
/
OPmenu.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file defines the menu items when right-clicking over nodes in
Houdini.
Files named the same (ie. OPmenu.xml) can exist in $HOME/houdiniX.Y/
directory and will supplement the original definitions found in
$HFS/houdini/ (aka $HH).
The format in this file is similar to the format in $HH/MainMenuMaster
except that it uses the <menuDocument> and <menu> tags instead of
<mainMenu> and <menuBar>. See the comments in that file for more advanced
customization abilities.
Note that the id's correspond to their hotkeys with the h.pane.wsheet.
prefix (where available). For example, the item with id,
"opmenu.flag_display", refers to the action in the hotkeys manager as
"h.pane.wsheet.opmenu.flag_display".
Also note that you can specify which context a particular menu item shows
up in. To do this, add a context property:
<context>
<networkCategory>Object</networkCategory>
</context>
Or, for multiple contexts, a comma-separated list:
<context>
<networkCategory>Object,Sop,Dop</networkCategory>
</context>
Or use an expression to determine if the menu item appears in the current
context. For example, to make the menu item appear only if the node is an
Object node:
<context>
<expression>kwargs["node"].type().category().name() == "Object"</expression>
</context>
For context expressions and menu scripts, a 'kwargs' python dictionary is
provided with the following values:
'node' : The node that the menu was opened for.
'toolname' : The menu item's hotkey id (ie. the element's id
prefixed with h.pane.parms.)
'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.
-->
<menuDocument>
<!-- menuDocument can only contain 1 menu element, whose id is
implicitly "root_menu"
-->
<menu>
<scriptItem id="opmenu.sop_object_merge_selection">
<label>Object Merge selection</label>
<context>
<networkCategory>Sop</networkCategory>
</context>
<scriptCode><![CDATA[
outNode = kwargs["node"]
outNodeName = str(outNode)
outNodePos = outNode.position()
inNodeName = ""
parentPath = outNode.parent()
parentPath = parentPath.path()
parent = hou.node(parentPath)
if outNodeName.startswith("OUT"):
inNodeName = outNodeName.replace("OUT", "IN")
else:
inNodeName = "IN_" + outNodeName
inNodeName = inNodeName.upper()
objMerge = parent.createNode('object_merge', inNodeName)
objMerge.setPosition(outNodePos)
moveValue = (0, -1)
objMerge.move(moveValue)
objMerge.parm('objpath1').set(objMerge.relativePathTo(outNode))
objMerge.parm('xformtype').set(1)
color = hou.Color((0.29, 0.565, 0.886))
objMerge.setColor(color)
]]></scriptCode>
</scriptItem>
</menu>
</menuDocument>