Changing DataType of a Value Node
-
Hi,
Apologies for this rudimentary question. Can't find any related reference in the forum.
But basically, I want to change the dataype of a Value Node from the
Float
(the default) toVector 2
.I already used the str values for the node inspector view.
Code I used. It does not error out but at the same time it does not work.
value_node.SetValue("net.maxon.datatype.id", "net.maxon.parametrictype.vec<2,float>") value_node.SetValue("id", "net.maxon.parametrictype.vec<2,float>") value_node.SetValue("Id", "net.maxon.parametrictype.vec<2,float>") value_node.SetValue("datatype", "net.maxon.parametrictype.vec<2,float>")
-
I can still change the data type through the following code:
datatype_port = value_node.GetInputs().FindChild("datatype") datatype_port.SetDefaultValue("net.maxon.parametrictype.vec<2,float>")
But I'm still interested in using the
SetValue
method since it is a bit more streamlined. No need to specify if inputs/outputs. etc. -
Hi @bentraje,
Nodes and ports are GraphNode. A GraphNode can store any kind of maxon Data. Using SetValue or SetDefaultValue on the "True Node" level will not change the value of a port. That is why you still need to find the port you want to change the value.
SetDefaultValue internally encapsulate the value in a maxon.Data and use the SetValue function to define the value for the ID
DESCRIPTION::DATA::BASE::DEFAULTVALUE
.I do not see any advantage using SetValue instead of SetDefaultValue.
While the GraphNode can receive any kind of Maxon Data, you can still define the DataType it should use. You must use the function SetValue to define the ID "fixedtype". In c++ you would do something like this:
port.SetValue(nodes::FixedPortType, GetDataType<neutron::OBJECT_FLAGS>()) iferr_return;
.
Unfortunately, you cannot do it with python because you cannot define the datatype.If the Datatype is not defined, it will be deducted from the incoming or outgoing connection.
In the case of the "Type" node, you are defining the port's value with this ID "net.maxon.parametrictype.vec<2,float>". This ID will allow the system to call the right CoreNode to manage this kind of DataType. The Datatype of this port is
maxon::Id
.I hope it is a bit clearer. I will try to add that to one of our manuals or in the documentation itself.
Cheers,
Manuel