Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Changing DataType of a Value Node

    Cinema 4D SDK
    2023 python
    2
    3
    514
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bentraje
      last edited by

      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) to Vector 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>")
      

      e15ae6f2-eb71-4b12-af5e-80b09b1c253a-image.png

      1 Reply Last reply Reply Quote 0
      • B
        bentraje
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          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

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 1
          • First post
            Last post