Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Unable to Modify the Input Port of the Math Node

    Cinema 4D SDK
    r20 python
    2
    3
    584
    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 bentraje

      Hi,

      I'm trying to create a math node and modify its corresponding Input[2]. However, it gives me an error TypeError: __setitem__ got unexpected type 'float' I tried with an integer but it also gives me an error.

      Is there a way around this?
      Thank you for looking at the problem.

      You can see the code here:

      import c4d
      
      # Main function
      def main():
          cube = c4d.BaseObject(c4d.Ocube)
          doc.InsertObject(cube)
          expresso = cube.MakeTag((c4d.Texpresso))
          nodemaster = expresso.GetNodeMaster()
          
          math_node = nodemaster.CreateNode(nodemaster.GetRoot(), c4d.ID_OPERATOR_MATH, None, x=0, y=0)
          
          # This line works
          math_node[c4d.GV_MATH_FUNCTION_ID] = 2 
          
          # This line does not work. The '[2000,1001]' was retrieved by dragging the Input[2] to the console. 
          math_node[2000,1001] = -1.0   
        
          c4d.EventAdd()
      
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        the "input" parameters are dynamically created parameters. So it appears they need a little bit more love.

        It seems to work using the fully qualified DescID and SetParamter().

        subContainerID = c4d.DescLevel(2000, c4d.DTYPE_SUBCONTAINER, c4d.ID_OPERATOR_MATH)
        inputID = c4d.DescLevel(1001, c4d.DTYPE_REAL, c4d.ID_OPERATOR_MATH);
        paramID = c4d.DescID(subContainerID, inputID)
        math_node.SetParameter(paramID, 99.9, c4d.DESCFLAGS_SET_0)
        

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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

          RE: appears they need a little bit more love.
          Thanks for the clarification. The code works as expected!

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