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

    Changing Math node input value Xpresso

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 485 Views
    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.
    • H Offline
      Helper
      last edited by

      On 23/11/2017 at 06:54, xxxxxxxx wrote:

      Hi everyone,

      I'm trying to change a math node value and unfortunately can't do it with:

      math[0][2000, 1001] = 1.0
      

      it gives the TypeError: __setitem__ got unexpected type 'float'.
      The error appears with any assigned value type.

      Interestingly enough if I change the value manually first and than run the line it works fine.
      Don't understand what I'm missing.

      Thank you very much in advance! 🙂

      Andre

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 23/11/2017 at 07:14, xxxxxxxx wrote:

        import c4d
          
        def main() :
            nodeMaster = doc.GetActiveTag().GetNodeMaster()
            node = nodeMaster.GetRoot().GetDown()
            
            # GET
            lv1 = c4d.DescLevel(2000, c4d.DTYPE_SUBCONTAINER, 0)
            lv2 = c4d.DescLevel(1000, c4d.DTYPE_REAL, 0) # or DTYPE_DYNAMIC that will automaticly adapt
          
            print node.GetParameter(c4d.DescID(lv1, lv2), c4d.DESCFLAGS_GET_0)
            
            # SET
            lv1 = c4d.DescLevel(2000, c4d.DTYPE_SUBCONTAINER, 0)
            lv2 = c4d.DescLevel(1000, c4d.DTYPE_DYNAMIC, 0)
          
            node.SetParameter(c4d.DescID(lv1, lv2), 50.0, c4d.DESCFLAGS_SET_0)
            c4d.EventAdd()
          
        if __name__=='__main__':
            main()
          
        
        

        As you may know or not, [] operators are just a python wrapper around Get/SetParameter, and sometime it fails. So you need to build it yourself

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 23/11/2017 at 07:34, xxxxxxxx wrote:

          Hi Graphos,

          It works great and understand better the containers.

          Thank you very much once again! You are a live saver and a technical wizard 😄

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