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. masterofthejack
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    masterofthejack

    @masterofthejack

    0
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    masterofthejack Unfollow Follow

    Latest posts made by masterofthejack

    • RE: New Child Render settings with python

      Thank you @ferdinand, I'll need to work out how I implement but once again a thorough and considered reply....

      posted in Cinema 4D SDK
      M
      masterofthejack
    • RE: New Child Render settings with python

      Hi @ferdinand
      Thanks so much for your comprehensive reply, very interesting. I couldnt emulate your result, as in the childs behaviour was still unique but I can see trying to do this will be problematic. As this script is built to generate a template to begin with I will just loop a step into our process which dictates to the creator to select all settings inside the children to inherit settings, one cannot completely omit manual tasks but one can try.

      One more problem Im having is camera that is apart of my setup (the camera that is the child of the object Im setting the dimensions with) doesnt update its frustrum or aspect ratio until I manually change the render dimensions in the newly created render settings slightly and return to the value created just to have it update in the veiwport, wonderingif there is some sort of update function I can include to do this.

      I should mention that the camera has some xpresso attached that sets its frustrum to lock onto a plane regardless of its position, I developed it to behave much like an "nDisplay" from Unreal engine. Developing this script was integral for us to quickly set POV per projected space for the purpose of immersive projection content. Thank you for all your help so far, if I could share my setup and scene with you, it might make more sense but I understand this space is probably not meant for that.

      posted in Cinema 4D SDK
      M
      masterofthejack
    • RE: New Child Render settings with python

      I should mention also that the Object needs a camera as its child also. This setup is specific to a pipeline we are implementing in our studio.

      Thanks

      posted in Cinema 4D SDK
      M
      masterofthejack
    • New Child Render settings with python

      Hi,

      I am trying to generate a "new child" of a master render setting in python whilst trying to keep the values in that child to inherit from the parent, however I can only clone or copy the settings which make the values unique and I have to tell the child by hand afterwards to inherit the settings. Is there anyway to create a child in Python that will automatically inherit the masters settings? Here is my code, it generates a take as well and assigns a camera and render dimensions based on the objects name (i.e. Object_3840x2160):

      import c4d
      
      def show_alert(message):
          dlg = c4d.gui.MessageDialog(message)
          return dlg
      
      def main():
          # Get the active Cinema 4D document
          doc = c4d.documents.GetActiveDocument()
          take_data = doc.GetTakeData()
      
          # Retrieve information about the selected object
          sel_object = doc.GetActiveObject()
          object_name = sel_object.GetName()
          active_object = doc.GetActiveObject()
      
          # Check if the object name follows the correct format "NAME_WIDTHxHEIGHT"
          name_parts = object_name.split("_")
          if len(name_parts) != 2:
              show_alert("Please make sure the object's name follows the format: NAME_WIDTHxHEIGHT")
              return
      
          width_height_parts = name_parts[1].split("x")
          if len(width_height_parts) != 2:
              show_alert("Please make sure the object's name follows the format: NAME_WIDTHxHEIGHT")
              return
      
          try:
              width = int(width_height_parts[0])
              height = int(width_height_parts[1])
          except ValueError:
              show_alert("Please make sure WIDTH and HEIGHT are whole numbers in the format: NAME_WIDTHxHEIGHT")
              return
      
          def find_camera_child(obj):
              if not obj:
                  return None
      
              for child in obj.GetChildren():
                  if child.GetType() == c4d.Ocamera:
                      return child
      
              return None
      
          # Find a camera as a child of the active object
          camera_child = find_camera_child(active_object)
      
          if camera_child:
              print(f"Found camera child: {camera_child.GetName()}")
          else:
              print("No camera child found.")
      
          # Create a new take and set its properties
          new_take = take_data.AddTake("", None, take_data.GetMainTake().GetDown())
          if camera_child:
              new_take.SetCamera(take_data, camera_child)
      
          take_name = name_parts[0]
          new_take.SetName(take_name)
      
          # Activate the newly created take and trigger an update
          take_data.SetCurrentTake(new_take)
          c4d.EventAdd()
      
          # Retrieve active render settings and create new ones
          active_render_settings = doc.GetActiveRenderData()
          #active_render_data = active_render_settings.GetClone
          parent_render_settings = active_render_settings.GetUp() or active_render_settings
          new_render_settings = active_render_settings.GetClone()
          new_render_settings_name = name_parts[0]
          new_render_settings.SetName(new_render_settings_name)
      
          # Set the resolution width and height in the new render settings
          new_render_settings[c4d.RDATA_XRES] = width
          new_render_settings[c4d.RDATA_YRES] = height
          print(f"Set resolution: {width}x{height}")
      
          # Insert the new render settings after the last sibling or as the first child
          last_sibling = parent_render_settings.GetDownLast()
          if last_sibling:
              new_render_settings.InsertAfter(last_sibling)
          else:
              new_render_settings.InsertUnder(parent_render_settings)
      
          # Set the new render settings as the active render data and trigger an update
          doc.SetActiveRenderData(new_render_settings)
          new_take.SetRenderData(take_data, new_render_settings)
          c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
      
      if __name__ == "__main__":
          main()
      
      posted in Cinema 4D SDK 2024 python
      M
      masterofthejack
    • RE: Creating shaders from PSD files

      Hi Been a few years now, any changes on this, I would love a script that iterated through a PSD file, create a material for each layer and set the Alphas for each layer

      posted in Cinema 4D SDK
      M
      masterofthejack