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
    • Register
    • Login
    1. Home
    2. gsmetzer
    G
    • Profile
    • Following 0
    • Followers 0
    • Topics 16
    • Posts 48
    • Best 1
    • Controversial 0
    • Groups 0

    gsmetzer

    @gsmetzer

    1
    Reputation
    53
    Profile views
    48
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    gsmetzer Unfollow Follow

    Best posts made by gsmetzer

    • RE: Multiple unique render files from same file?

      Yes, I was able to make it work by pausing the script until IsRendering returns false. It is working really nice, naming my jpegs correctly and is very simple to setup by just dropping the objects I want rendered into the In/Ex list. This workflow is great when I have over 100 objects I want rendered on their own.

      I could use RenderDocument and the Take system but I have not developed a python way to iterate through scene objects - make object visible - assign a take with visibility settings - render with only that object visible. I do believe it is possible and another route I could take. I may try to develop this method as well to compare workflow but I find the Take system cumbersome for bigger jobs.

      Cheers,
      Gabriel

      posted in General Talk
      G
      gsmetzer

    Latest posts made by gsmetzer

    • Getting radius of text during rendering

      I am able to get the bounding box of text with .GetRad() and it works nicely in the viewport. However, when I render my radius goes to zero. I created a simple scene to show the problem. Rad_NotUpdatingRender_01.c4d Is there any hacks to get the radius working in render?

      In a python Generator

      import c4d
      
      
      #I'm trying to get the bounding box of each text object working in the renderer
      #The viewport works fine, but when I render the 'widths' list goes to [0,0]
      
      children = op.GetChildren()
      
      widths = []
      #loop through children  (text objects)
      for i in range(len(children)):
          
          #get the radius of each child
          radius = children[i].GetRad()
          #bbox = c4d.utils.GetBBox(children[i], children[i].GetMg())[0].x
          
          #build list of widths.
          widths.append(round(radius.x))
      
      print(widths)
      
      def main():
          #send width list to another object to see in the render
          op[c4d.ID_USERDATA,1][c4d.PRIM_TEXT_TEXT] = str(widths)
      
          return
      
      posted in Cinema 4D SDK 2024 python
      G
      gsmetzer
    • RE: New Forum Announcement

      @ferdinand Thank you! Yes, hopefully Google will index the new site soon.

      posted in News & Information
      G
      gsmetzer
    • RE: New Forum Announcement

      Where is the API? A google search for the past two weeks gives me a 404 error?

      posted in News & Information
      G
      gsmetzer
    • RE: How to evenly distribute objects of different 'width'

      I was able to create the same outcome with this script in a python generator and sever cube objects as children of the generator. Everything works great and I am able to change width and offset the axis and all my child objects stack nicely side by side. This is very similar to the popular Autolayout effect in Figma.

      Unfortunately I cannot get the correct center from utils.BBox so if one of my child objects is a hierarchy I can't get the correct outcomes.

      This code might be a bit easier to read for python juniors like myself.

      def main():
          parent = op
          child = parent.GetChildren()
          count = len(child)             #number of assets
          layout = c4d.Vector( 0 ,0 , 0 )
          padding = op[c4d.ID_USERDATA,3]
      
          for i in range(0,count):  #loop through all children
      
              box = c4d.utils.GetBBox(child[i], child[i].GetMg())  #BBox is a tuple with (center,radius)
              pre = c4d.utils.GetBBox(child[i-1], child[i-1].GetMg())  #BBox is a tuple with (center,radius)
              center = child[i].GetMp()
              preCenter = child[i-1].GetMp()
              
              layout += box[1] - center + pre[1] + preCenter + padding
              child[i][c4d.ID_BASEOBJECT_ABS_POSITION,c4d.VECTOR_X] = layout.x
              
              continue
        
      
      
      posted in Cinema 4D SDK
      G
      gsmetzer
    • RE: Output multiple file types from one render.

      The API does appear to have movie saving features. https://developers.maxon.net/docs/py/2023_2/modules/c4d.bitmaps/MovieSaver/index.html

      posted in Cinema 4D SDK
      G
      gsmetzer
    • RE: Output multiple file types from one render.

      I see. Re-rendering with each screen resolution would be highly cumbersome. It would be great to have a tool that works like this in Cinema. With soooo many different screen resolutions these days it would really come in handy.

      posted in Cinema 4D SDK
      G
      gsmetzer
    • Output multiple file types from one render.

      Happy New Year!

      I want to write a script that outputs multiple files from one render and saves into one or more folders. For example:

      I select a rendered image sequence from the picture viewer. Click my script that has multiple options to save multiple versions of the render.
      -One .mov at square aspect resolution
      -...add different resolution/aspect ratios etc.
      -one .mpg at square aspect resolution
      -....add different resolution/aspect ratios etc.
      -one still image
      -....add different resolution/aspect ratios etc.

      I see this dialogue but I want to somehow batch perform these operations. Any ideas how I might implement this with python? Screenshot 2024-01-04 at 9.32.43 AM.png

      posted in Cinema 4D SDK 2024 python macos windows
      G
      gsmetzer
    • RE: Multiple unique render files from same file?

      Ok, I ran into the issue of polling the BatchRender.IsRendering. I don't have the python skills to do multi-threading to check when a render is complete. I was able to hack in a time.sleep function but it is very problematic for longer renders and crashes a lot.

      Instead I went the route of Takes though Take are a bit cumbersome to setup but it is working nicely. I'll post the code here for anyone looking to do something similiar. I can just RenderAllTakes command and get each object rendered with its name using a $Take render token.

      def main():
          doc = c4d.documents.GetActiveDocument()
      
      
          inEx = op[c4d.ID_USERDATA,4] # In/Exclude User Data
      
      
      
          for i in range(0 , op[c4d.ID_USERDATA,4].GetObjectCount()):  #Iterate through each shot based on our shot slider in user data
      
              activeObj = inEx.ObjectFromIndex(doc, i) #deterimine which object is active
      
              if op[c4d.ID_USERDATA,1] == i:
                  activeObj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = False  #turn visibility On
                  activeObj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = False
                  render_filename = inEx.ObjectFromIndex(doc, i).GetName()  #Gets the name of the currently active object
                  op[c4d.ID_USERDATA,5] = render_filename
      
              else:
                  activeObj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = True  #turn visibility Off
                  activeObj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = True
      
          c4d.EventAdd()
      
      ################   SEND ALL
      
      def BuildTakes():
      
      
          #Sequencer()
          takedata = doc.GetTakeData()
          obj = doc.GetActiveObject()
          #print( Description.GetParameterI(op[c4d.ID_USERDATA,1], ar=None))
      
          inEx = op[c4d.ID_USERDATA,4] # In/Exclude User Data
      
      
      
          for i in range(0,op[c4d.ID_USERDATA,4].GetObjectCount()):
              #Sequencer()
      
              take = takedata.AddTake(inEx.ObjectFromIndex(doc, i).GetName(), None, None)
      
              take.FindOrAddOverrideParam(takedata, obj                         , c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 1),c4d.DescLevel(1)), i ,  backupValue=None, deleteAnim=False)
              take.FindOrAddOverrideParam(takedata, inEx.ObjectFromIndex(doc, i), c4d.ID_BASEOBJECT_VISIBILITY_EDITOR, False, backupValue=None, deleteAnim=False)
              take.FindOrAddOverrideParam(takedata, inEx.ObjectFromIndex(doc, i), c4d.ID_BASEOBJECT_VISIBILITY_RENDER, False, backupValue=None, deleteAnim=False)
              #op[c4d.ID_USERDATA,1] = 0
              #Sequencer()
              #c4d.MSG_DESCRIPTION_CHECKUPDATE
      
      
          #Sequencer()
          #c4d.EventAdd()
      
      def ClearTakes():
          tk = doc.GetTakeData()
          tk.ResetSystem()
      
      posted in General Talk
      G
      gsmetzer
    • RE: Multiple unique render files from same file?

      Yes, I was able to make it work by pausing the script until IsRendering returns false. It is working really nice, naming my jpegs correctly and is very simple to setup by just dropping the objects I want rendered into the In/Ex list. This workflow is great when I have over 100 objects I want rendered on their own.

      I could use RenderDocument and the Take system but I have not developed a python way to iterate through scene objects - make object visible - assign a take with visibility settings - render with only that object visible. I do believe it is possible and another route I could take. I may try to develop this method as well to compare workflow but I find the Take system cumbersome for bigger jobs.

      Cheers,
      Gabriel

      posted in General Talk
      G
      gsmetzer
    • Multiple unique render files from same file?

      This concept of rendering multiple unique render paths was touched on here: https://developers.maxon.net/forum/topic/13061/adding-multiple-cameras-from-a-single-file-to-the-render-queue/22

      The solution works pretty well but duplicates the source file multiple times.

      My goal is to have a workflow where multiple objects in the same file can be rendered with their object name as their own jpeg. I am using an In/Ex User data and python generator to achieve this. The problem is the jpegs get overwritten each time.
      I am trying to figure out a way to add a batch render element that waits until the render completes then adds a new file with the next object iteration.

      I am posting my scene file and python here. MultiSavePath_01.c4d

      import c4d
      from c4d import gui, storage
      import os
      import fileinput
      
      #The goal is to render multiple files with unique render paths from this one file.   I have this code in a python generator
      #with and in/ex user data, the code iterates through in/ex updating the render path and starting the render.  The problem
      #is the render path and jpeg get overwritten to the same file.   How do I render four separete jpeg files named Cylinder, Sphere, Cube and Figure?
      
      #thank you for any help!
      
      def message(id,data) :   #Button listener
          if id == c4d.MSG_DESCRIPTION_CHECKUPDATE:
              if data["descid"][1].dtype == c4d.DTYPE_BUTTON or c4d.DTYPE_LONG:
                  buttonID = data["descid"][1].id
      
                  if buttonID == 2:
                     SendShotsToRender() #SEND TO RENDER
      
                 
      
      
      
      def main():
      
          return
      
      
      def SendShotsToRender():
      
          print("Send Shots To Render")
          doc = c4d.documents.GetActiveDocument()
          br = c4d.documents.GetBatchRender()
          rd = doc.GetActiveRenderData()
          
          
          br.Open() #Open the render queue window
          c4d.CallCommand(465003519) # Clear render queue of old render files
          inEx = op[c4d.ID_USERDATA,4] # In/Exclude User Data
          inExCount = inEx.GetObjectCount() #how many shots in our In/Exclude
          shot = op[c4d.ID_USERDATA,1] #The currently active shot
      
      
      
      
          for i in range(0,inExCount):  #Iterate through each shot based on our shot slider in user data
      
              activeObj = inEx.ObjectFromIndex(doc, i) #deterimine which object is active
              render_filename = inEx.ObjectFromIndex(doc, i).GetName()  #Gets the name of the currently active object
      
              rd[c4d.RDATA_PATH] = render_filename  #Set the render files name
              
              source_file = doc.GetDocumentPath() + "/" + doc.GetDocumentName() #get the source document path
              
              br.AddFile(source_file,0)  #Add the source file
              
              br.SetRendering(c4d.BR_START) #start rendering
              
              #print(br.GetElementStatus(c4d.RM_FINISHED))  #Is there a way I can wait for the render to finish then delete the file update the path and add a new one?
              
              #br.DelFile(source_file)
      
      
              if shot != i:
      
      
      
      
                      activeObj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = True  #turn visibility On
                      activeObj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = True
      
              else:
                      activeObj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = False  #turn visibility Off
                      activeObj[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = False
      
              print(i,render_filename)
      
              op[c4d.ID_USERDATA,4] = inEx  #write back to the IN/EXCLUDE list
      
      
      
      
      
      
      
      
      
      
      
      posted in General Talk programming download
      G
      gsmetzer