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
    1. Maxon Developers Forum
    2. robpayne
    R
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 3
    • Best 1
    • Controversial 0
    • Groups 0

    robpayne

    @robpayne

    2
    Reputation
    19
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    robpayne Unfollow Follow

    Best posts made by robpayne

    • Cannot set layer parameter for capsules in 2024.3.1

      In 2024.3.1 python cannot set the layer parameter of a Capsule object. Other object types seem to be unaffected. Console shows the error: “AttributeError: parameter set failed”
      Screenshot 2024-02-23 at 18.21.31.jpeg

      Reproduction:

      • Open Cinema 4D
      • Add new layer in the Layer Manager
      • Add a capsule object to the scene (e.g. Polygon Bevel)
      • Run the script below in the Script Manager to set layer parameter for all objects
      import c4d
      
      def main() -> None:
          
          # Get first layer
          myLayer = doc.GetLayerObjectRoot().GetDown()
          
          # Get objects in scene
          allObjects = doc.GetObjects()
          
          # Set layer attribute for objects in scene
          for i in range(len(allObjects)):
              allObjects[i][c4d.ID_LAYER_LINK] = myLayer
              c4d.EventAdd()
          
      if __name__ == '__main__':
          main()
      

      Result

      • The capsule layer is NOT set
      • Error appears in console in the python tab

      Versions

      • [NOK] 2024.3.1
      • [OK] 2024.2.0

      Tested on:

      • Windows 11 Pro (23H2)
      • OSX Monterey 12.6.3
      posted in Cinema 4D SDK python 2024
      R
      robpayne

    Latest posts made by robpayne

    • Cannot set layer parameter for capsules in 2024.3.1

      In 2024.3.1 python cannot set the layer parameter of a Capsule object. Other object types seem to be unaffected. Console shows the error: “AttributeError: parameter set failed”
      Screenshot 2024-02-23 at 18.21.31.jpeg

      Reproduction:

      • Open Cinema 4D
      • Add new layer in the Layer Manager
      • Add a capsule object to the scene (e.g. Polygon Bevel)
      • Run the script below in the Script Manager to set layer parameter for all objects
      import c4d
      
      def main() -> None:
          
          # Get first layer
          myLayer = doc.GetLayerObjectRoot().GetDown()
          
          # Get objects in scene
          allObjects = doc.GetObjects()
          
          # Set layer attribute for objects in scene
          for i in range(len(allObjects)):
              allObjects[i][c4d.ID_LAYER_LINK] = myLayer
              c4d.EventAdd()
          
      if __name__ == '__main__':
          main()
      

      Result

      • The capsule layer is NOT set
      • Error appears in console in the python tab

      Versions

      • [NOK] 2024.3.1
      • [OK] 2024.2.0

      Tested on:

      • Windows 11 Pro (23H2)
      • OSX Monterey 12.6.3
      posted in Cinema 4D SDK python 2024
      R
      robpayne
    • RE: Unable to set override in take

      Hi @ferdinand , thank you for kindly informing me, and for your guidance.

      I was able to achieve a working solution by simplifying. This Script Manager script:

      1. creates a cube
      2. creates a take
      3. creates an override with new width for the cube
      import c4d
      
      def main() -> None:
      
          # Instantiate a cube – for test only
          obj = c4d.BaseObject(c4d.Ocube)
          doc.InsertObject(obj)
      
          # Get take structure
          takeData = doc.GetTakeData()
          mainTake = takeData.GetMainTake()
      
          #Insert new take
          newTake = takeData.AddTake("Test", mainTake, None)
      
          #Capture descID of paramater to override
          descID = c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_LEN, c4d.DTYPE_VECTOR, 0), c4d.DescLevel(c4d.VECTOR_X,c4d.DTYPE_REAL,0))
      
          #Set take override
          newTake.FindOrAddOverrideParam(takeData, obj, descID, 10)
          
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      

      The problem I had before was my descID was improperly collected. I needed to specify datatypes, as is the case here.

      Many thanks,
      Rob

      posted in Cinema 4D SDK
      R
      robpayne
    • Unable to set override in take

      Hi, I am having difficulty generating take overrides with ‘FindOrAddOverrideParam()’. When I run my script it creates a set of takes with an override but no value.

      My script does ‘work’ if I use ‘OverrideNode()’ instead, but this overrides all of the parameters for the given object, which is much more than I want or need.

      My code runs from a Python tag and is activated by a user data button. The intention is to increment the user data by one for each child object.

      Any assistance would be greatly appreciated.

      import c4d
      
      def createTake():
          # Get existing take structure
          take_data = doc.GetTakeData()
          main_take = take_data.GetMainTake()
      
          # Get Selector child objects
          obj = op.GetObject()
          
          # Create header take
          select_take = take_data.AddTake("Selector", main_take, None)
          select_take.SetName(obj.GetName())
      
          child = obj.GetDown()
      
          #records original user value, used with OverrideNode()
          originalSelection = obj[c4d.ID_USERDATA,2]
      
          n = 1
          while child:
              print (f"n{n}  obj {child.GetName()}")
              childTake = take_data.AddTake("Selection", select_take, None)
              childTake.SetName(child.GetName())
              obj[c4d.ID_USERDATA,2] = n #increment userdata, used with OverrideNode()
              descId = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(2))
              #childTake.OverrideNode(take_data, obj, False)
              overrideNode = childTake.FindOrAddOverrideParam(take_data, obj, descId, n)
              n = n + 1
              child = child.GetNext()
          
          obj[c4d.ID_USERDATA,2] = originalSelection #restores original user value, used with OverrideNode()
          c4d.EventAdd()
      
      
      def message(msg_type, data):
          if msg_type == c4d.MSG_NOTIFY_EVENT:
              event_data = data['event_data']
              if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND:
                  desc_id = event_data['msg_data']['id']
                  if desc_id[1].id == 5: # The ID of the User Data
                      print ("Button Pressed")
                      createTake()
      
      def main():
          obj = op.GetObject()
      
          # Check if we already listen for message
          if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE):
              obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())
      
      posted in Cinema 4D SDK python
      R
      robpayne