Getting and Setting Parameters¶
The parameters of a node are organized in a tree inside the node. The tree allows better organization of nodes with many parameters, avoids parameter name collisions, and makes it simple to construct more complex re-usable parameter definitions.
The function getParameters()
returns the root parameter of a
node. The children of that root parameter are the top level entries you see in
the Parameters tab. For example, to get the children of the root
parameter on a node enter:
>>> node = NodegraphAPI.GetNode("PrimitiveCreate")
>>> for p in node.getParameters().getChildren():
... print(p)
<Parameter 'name'>
<Parameter 'type'>
<Parameter 'fileName'>
<Parameter 'previewTexture'>
<Parameter 'previewAlpha'>
<Parameter 'enableClippingPlane'>
<Parameter 'reverseClippingDirection'>
<Parameter 'transform'>
<Parameter 'makeInteractive'>
<Parameter 'includeBounds'>
<Parameter 'viewerPickable'>
You can get a complete text dump of all parameters on a node using
getXML()
. For example, to see the XML structure of all the
parameters on a node:
>>> print (node.getParameters().getXML())
<group_parameter name="PrimitiveCreate">
<string_parameter name="name" value="/root/world/geo/primitive"/>
<string_parameter name="type" value="sphere"/>
...
</group_parameter>
-
Parameter.
getType
() → str¶ Returns a string defining the type of this parameter. This string will be one of ‘number’, ‘numberArray’, ‘string’, ‘stringArray’, ‘curve’, ‘group’, ‘opaque’, ‘floatVector’ or ‘scenegraphAttr’.
-
Parameter.
getFullName
(includeNodeName: bool = True) → str¶ Returns the full string name of this parameter, where the parent hierarchy is separated by dots.
-
Parameter.
getName
() → str¶ Returns the string name of this parameter.
-
Parameter.
setName
(newName: unicode) → str¶ Sets the string name of this parameter. If a sibling parameter is already named
newName
, a numeric index will be added to the end and incremented until a unique name is generated. This unique name will be returned. This method only has an effect on parameters that are children of dynamic groups.
-
Parameter.
getParent
() → NodegraphAPI.Parameter¶ Returns the parent parameter of this parameter, or
None
if this is a top-level parameter.
-
Parameter.
getIndex
() → int¶ Returns the index of this parameter within its parent.
-
Parameter.
reparentAtomic
(parent: NodegraphAPI.Parameter) → str¶ Atomically reparents this parameter to the given
parent
. This should be used in place of sequential calls toremoveChild()
andaddChild()
to avoid excessive XML regeneration. Returns the new path of the child under the new parent.
Getting Values¶
To return the value of a parameter, use getParameter().getValue()
. For
example, to return the value of the name parameter at time 0, enter the
following:
>>> node.getParameter('name').getValue(0)
-
Node3D.
getParameter
(name: str) → Parameter¶ Parameters: name ( str
) – The (dot-delimited full) name of the (nested) parameter to return.Returns: A (nested) parameter by (dot-delimited full) name, or None
if this node does not contain a parameter of the given name.
-
Node3D.
getParameters
() → GroupParameter¶ Returns: The top-level group parameter that contains all of this node’s parameters.
-
Parameter.
getValue
(time: float) → object¶ Returns the value of this parameter at the given
time
. This value may be a string, a float or anFCurve
.
Setting Values¶
Values on a node are set using getParameter().setValue()
. As node behavior
is set by parameters who’s values can change over time, you must specify a
value and a time, when setting a parameter.
For example, to change the type parameter of a PrimitiveCreate node to “teapot”, when time is 10, enter the following:
node.getParameter('type').setValue("teapot", 10)
-
Parameter.
setValue
(value: object, time: float, final: bool = True, sendNotifyMessage: bool = True) → None¶ Sets the value of this parameter at the given time. If this is an interactive value, set
final
toFalse
to avoid sending redundant nodegraph messages.
-
Parameter.
finalizeValue
() → None¶ Hardens the value of tihs parameter after it has been interactively modified. This simply calls through the
sendSignal_finalize
.