1 """Functions used by the ApplyMaterial node"""
2
3 import nuke
4 import nukescripts.panels
5
6
8 """A dialog box with a SceneView_Knob for choosing from a tree of names.
9
10 The easiest way to use this is via the chooseObjectName function from this
11 module, e.g.:
12
13 chooseObjectName(["/root/foo", "/root/bar", "/root/bar/baz"])
14
15 This will create and display the dialog as a modal popup and give you the
16 selected name, or None if cancel was pressed.
17 """
18
24
26 """Get the name selected in the SceneView_Knob."""
27 return self.sceneView.getHighlightedItem()
28
29
46
47
49 """Given a GeoInfo object, return the value of its 'name' attribute. If there is no such attribute, return None."""
50 attrCtx = geo.attribContext('name', 3, 7)
51 if attrCtx is None:
52 attrCtx = geo.attribContext('name', 3, 6)
53 if attrCtx is not None:
54 attr = attrCtx.attribute
55 if attr is not None and len(attr) > 0:
56 return attr[0]
57 return None
58
59
61 if name is not None and name not in names:
62 fixedName = '/' + name
63 if fixedName in names:
64 return fixedName
65 return name
66