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 the parameter. It is one of ‘number’, ‘numberArray’, ‘string’, ‘stringArray’, ‘curve’, or ‘group’.
-
Parameter.
getNode
() → Node¶ Get the node that contains this parameter.
-
Parameter.
getFullName
(includeNodeName=True) → str¶ Returns the full string name of this parameter from the node. Parameters are separated by ‘.’ dots.
-
Parameter.
getName
() → str¶ Get the string name of this parameter.
-
Parameter.
setName
(name)¶ Set the string name of this parameter. If a sibling already has the given name, a numeric index will be added to the end and incremented until a unique name is generated. This will only work on parameters that are children of dynamic. Returns the actual new name of the parameter.
-
Parameter.
getParent
() → Parameter¶ Get the parent parameter of this parameter. Returns None if this is the top level parameter.
-
Parameter.
getIndex
() → int¶ Returns the index we are within our parent.
-
Parameter.
reparentAtomic
(newParentParameter)¶ Atomically reparent a parameter from its current parent to a new parent. This is used in place of sequential removeChild and addChild to avoid excess XML generation. Returns the new name of the parameter under the new parent, or None.
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) → Parameter¶ Returns a nested parameter by name. Separate children with ‘.’ dots. Returns None if not found.
-
Node3D.
getParameters
() → Parameter¶ Returns the top-level group parameter that contains all the node’s parameters.
-
Parameter.
getValue
(time) → str or float¶ Gets the value of the parameter at the given time. The value can be a string, a float, or an FCurve.
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, time, final=True, sendNotifyMessage=True)¶ Sets the value of the parameter at the given time. The value is a string or float. If this is an interactive value, set the ‘final’ keyword argument to False.
-
Parameter.
finalizeValue
()¶ Hardens the value of a parameter after it has been interactively modified. This simply calls through to sendSignal_finalize.