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
    • Recent
    • Tags
    • Users
    • Login

    Type Error using Init()

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 354 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 15/12/2015 at 07:24, xxxxxxxx wrote:

      Hi!

      I'm completely new to plugin programming and stumble my way through the doc and examples, but I'm stuck on an error. Maybe you guys can help me out.

      I'm trying to initalize description attributes from a .res file with the Init()/InitAttr() functions.
      The example from the doc is:

      import c4d
      
      def Init(self, node) :
          #please note, the desc element has to be a constant (id of your container element)
          self.InitAttr(host=node, type=float, desc=[c4d.PY_TUBEOBJECT_RAD])
          self.InitAttr(host=node, type=float, desc=[c4d.PY_TUBEOBJECT_IRADX])
      
          node[c4d.PY_TUBEOBJECT_RAD]= 200.0
          node[c4d.PY_TUBEOBJECT_IRADX] = 50.0
      

      When I follow the syntax I get the error: _  TypeError: Required argument 'id' (pos 3) not found_
      I assume, that the example is wrong and the 'desc' argument should be 'id', but I might be wrong about that.
      When I change it to 'id' the attributes are set correctly, but I get the error:  TypeError: Init expected bool, not None
      _
      _
      This might be unrelated, but the Init() function also seems to be called every time I edit an attribute in the description. Is it supposed to do that?

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

        On 15/12/2015 at 08:31, xxxxxxxx wrote:

        Hi and welcome to the Plugin Cafe!

        I'm sorry the example for NodeData.InitAttr() is wrong.
        desc parameter in the example is in fact callled id as you noticed. This will be fixed.

        You can find the Py-RoundedTube ObjectData example (this one run and is fixed) in the example s folder of the Python SDK documentation archive.

        Originally posted by xxxxxxxx

        This might be unrelated, but the Init() function also seems to be called every time I edit an attribute in the description. Is it supposed to do that?

        Yes this is normal. I won't go into details but this is because of the undo mechanism of Cinema.

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

          On 15/12/2015 at 08:54, xxxxxxxx wrote:

          Thank you for the quick response!

          I'm definitely going to check out the examples!
          Thanks again.

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