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
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. BigRoy
    3. Posts
    • Profile
    • Following 0
    • Followers 1
    • Topics 7
    • Posts 14
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by BigRoy

    • Managing render settings and getting list of expected output files.

      Hi everyone,

      Consider me a newbie, so these might be stupid beginner questions but I'm hoping all of you can point me into the right direction. My Cinema4D knowledge is rather limited but I'm looking to get more knowledge on how to manage render settings from Cinema4D with Python.

      I need to query each file that would be written out if a render completes. E.g. each render pass, render take, camera, etc. that would get written out to a separate file on disk, including knowing their colorspace. In my case, knowing what a render on Deadline would spit out at the end.
      I assume that'd essentially be just all 'enabled' takes and the output filenames specified with the tokens. Does Cinema4D provide any good API to get access to this? How renderer-specific are those save filepaths? e.g. does the same logic share between Redshift and other renderers, or would it quickly become e.g. renderer specific?

      For example I think I can do:

      import c4d
      import redshift
      
      doc = c4d.documents.GetActiveDocument()
      renderdata = doc.GetActiveRenderData()
      
      # Get the Redshift videoPost and render settings
      vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer)
      existing_aovs = redshift.RendererGetAOVs(vpRS)
      

      But I'd essentially be writing logic that seems related to Redshift alone, and I'd need to then write similar code for each renderer down the line. E.g. each redshift AOV can have color processing enabled/disabled on its own in Redshift. So getting the colorspace of the AOV images for example would easily get very specific to Redshift too? Any ideas?

      Just to compare, the USD API for example has "Render Products" with "Render Vars" logic that is all shared between each renderer, and thus from the USD data alone I can detect all the output files that would be written. Preferably I can get to similar single API from a C4D scene alone.

      What I need:

      • I need to know the expected output files that would be rendered from the current scene. What's the best way to get that?
      • How do I query the takes that would be rendered?
      • Preferably I can also set the render output filepath in a managed way in the pipeline too.
      • Get the output colorspace of each image.

      Preferably all of this, without actually needing render things - so I can validate certain outputs in advance, etc.


      Just adding these links for my own future reference:

      • Getting takes data from a plug-in, do not use get active document
      posted in Cinema 4D SDK python 2025 windows
      BigRoyB
      BigRoy
    • RE: Cinema4D 2025 get user data value parameter not accessible?

      Just to confirm - skipping the unwanted entries worked absolutely fine for my needs. And I was able to reproduce the behavior in Cinema4D 2023 too if I created such user data manually and tried to access it. So - no bug or regression, just my limited knowledge.

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • RE: Cinema4D 2025 get user data value parameter not accessible?

      Thanks so much - of course, it may very well be that something in Cinema4D may just be generating more user data than I expected to live there. As such, I'll just perfectly ignore any values that couldn't be parsed since in my case I only care about those that I put there from Python to begin with.

      Thanks for the quick and thorough reply.

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • Cinema4D 2025 get user data value parameter not accessible?

      It seems that triggering this logic in Cinema4D 2025 fails:

          for description_id, base_container in obj.GetUserDataContainer():
              key = base_container[c4d.DESC_NAME]
              value = obj[description_id]
      

      Which did not error in Cinema4D 2023 and 2024.
      With an error along the lines of:

          value = obj[description_id]
                  ~~~^^^^^^^^^^^^^^^^
      AttributeError: Parameter value not accessible (object unknown in Python)
      

      Source issue reported here
      Even though this same logic worked in Cinema4D 2023 and 2024.
      Is this a regression, or does my code need updating?

      Could it be failing on trying to get a value from a Group, e.g. as one created here:

                  # Create the group
                  group_bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_GROUP)
                  group_bc[c4d.DESC_NAME] = group
                  group_bc[c4d.DESC_SHORT_NAME] = group
                  group_bc[c4d.DESC_TITLEBAR] = True
                  group_bc[c4d.DESC_GUIOPEN] = False
                  group_id = node.AddUserData(group_bc)
      

      If so, how would I detect correctly which user data should be allowed to retrieve the values from?

      posted in Cinema 4D SDK 2025 python
      BigRoyB
      BigRoy
    • RE: Alembic Export Options Not Working

      Just want to confirm here that I'm facing this same issue - only setting the negative state first and then the positive state after seems to make this work. So, thanks for the workaround.

      Here's the reported bug on our pipeline: https://github.com/ynput/ayon-cinema4d/issues/6
      And this is what fixed it: https://github.com/ynput/ayon-cinema4d/pull/8

      Looking at 'what' fixes it this most definitely sounds like a bug.
      (I tested in Cinema4D 2023.2.2 on Windows 10)

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • RE: Import and managing 'merged' Alembic

      Hi Ilia, this is great - thanks so much. I was able to get what I needed using the LoadDocument it seems. Am I correct in understand that the document it 'opens' is only temporary and I do not have to ensure proper deletion (in memory) of the loaded document once I'm done with it?

      Other than that - part of my code is currently here. It's more of a "spare time" open-source pipeline development because I don't use Cinema4D myself but am hoping it can become useful for others - so thanks for the details!

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • Merged Alembic Generator object, how to check if it is a camera?

      When importing an Alembic it turns the objects into Alembic Generators. How can I, without making the objects editable detect whether the object is a camera or not?

      print(op.GetTypeName())
      

      Prints: Alembic Generator.

      posted in Cinema 4D SDK python
      BigRoyB
      BigRoy
    • RE: Register event callbacks for "new file", "open file", "save file" (hooks?)

      @m_adam said in Register event callbacks for "new file", "open file", "save file" (hooks?):

      Regarding new document, sadly there is no way to hook into that and the best way would be to have a MessageData, list all doc by calling c4d.documents.GetFirstDocument and then iterating them by calling BaseList2D.GetNext(). Since a document is a BaseList2D you can hash them and therefor know if there is a new document.

      So that would just be running on a timer then, with the hope that I 'trigger' on it swiftly enough? Doesn't fit my needs so dedicated SceneHooks I can register application wide would be a mad helper for this!


      Aside of that - was there still a way to 'add' the python generator object into the scene without it maybe serializing into the saved file? Like have a flag that says "Do not serialize"? (Also, Scene Hooks would still be better)

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • Update Xref filepath without user interaction

      I'm looking to update filepath of an Xref via Python without user interaction requiring the "Yes" on a popup dialog.

      This works:

      xref.SetParameter(
          c4d.ID_CA_XREF_FILE,
          filepath,
          c4d.DESCFLAGS_SET_USERINTERACTION,
      )
      

      But that basically means I will get this pop-up dialog:
      c0a78c0f-923a-4b74-87fc-d4536cfac6f5-image.png

      However I want to do this without any user interaction in-between. How can I force the update without requiring the c4d.DESCFLAGS_SET_USERINTERACTION flag.

      How can I update the filepath without the pop-up dialog?


      This has come up often before, see here:

      • http://developers.maxon.net/forum//post/63608
      • https://developers.maxon.net/forum/topic/14319/does-xref-or-xref-simple-are-now-accessible-with-python
      • http://developers.maxon.net/forum//post/63554

      But from back in 2020 through 2022 these remained lingering with "impossible". But hey, the future is bright and now. How do we do this? (From Python)

      posted in Cinema 4D SDK python 2023 windows
      BigRoyB
      BigRoy
    • RE: Register event callbacks for "new file", "open file", "save file" (hooks?)

      And of course just after I find this Python API: Document Events topic which seems to hit close to this.

      However - it seems it requires me to create an ACTUAL object in the scene if I understand correctly - which seems odd. Is there any way that I can make this work - inside the scene file within the pipeline, but have the Cinema4D file itself remain free of this when saved and shared with someone else? (Maybe we can exclude the node from persisting with the scene on saves, or alike?)

      Also, that does not allow me to respond to a "new" document being created?

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • Register event callbacks for "new file", "open file", "save file" (hooks?)

      I'm looking for a way via Cinema4D's Python API to respond to a user creating a new document (to e.g. apply certain default settings) and to respond to file open and file save (preferably a callback before save and after save) to respond with some custom pipeline logic as well.

      A google search and search over the SDK didn't get me anywhere. I did see Plugin Messages and Hooks but both didn't point me in the right direction to run python code on any of the mentioned events. At some point I thought MessageData was what I was looking for, but I couldn't find what ids it could capture and whether any were related to new document, saving document, opening documents, etc.

      posted in Cinema 4D SDK python 2023 windows
      BigRoyB
      BigRoy
    • Import and managing 'merged' Alembic

      Hi everyone,

      I'm trying to import an Alembic and then afterwards manage the loaded data (like being able to update versions) via Python. However, I'm already stuck at triggering the "Import Alembic" logic without user interventions (no dialogs). How would I do so?

      1. How to trigger "import alembic" and return the newly created objects?
      2. To update the alembics after I'm thinking of updating the filepaths on the Alembic paths, and removing any shapes that do not exist anymore in the alembic and creating new ones. Is there an Alembic API that comes with Cinema4D that allows me to query the contents of the alembic?
      3. I'd like to also update the "visibility" on updates - do I need to 'key' those, or is it capable of streaming those in? Since the checkbox appears to remain disabled for me?
        1663b22a-398e-4637-a39a-8ab7a26fadda-image.png

      Code snippet, documentation or links are greatly appreciated!


      Note: I'm not familiar with Cinema4D - I'm only trying to tackle the pipeline aspect of it for an open-source pipeline called AYON. So even for simple concepts it'd be nice to get the 'dummy" info about it.

      I'm looking to do this in 2023.2.2 and up.

      posted in Cinema 4D SDK python 2023
      BigRoyB
      BigRoy
    • RE: Custom menu in C4D top menu bar with custom Python commands

      @r_gigante Thanks, the command examples were exactly what I needed. And someone stating explicitly that I needed to create a command per menu entry made me help realize that too.

      I now have an Avalon menu - perfect.

      Bug with C4D and PYTHONPATH

      I did hit a C4D bug as I started setting up the pipeline integration, whenever there's an empty value in the list on PYTHONPATH then Python fails to run correctly in Cinema4D. More details here

      Icons. Are they .tiff only?

      I've tried to add an icon to the menu but I failed there. I tried to pass it a .svg icon like so:

      bitmap = c4d.bitmaps.BaseBitmap()
      bitmap.InitWith(path)
      

      And then providing that to c4d.plugins.RegisterCommandPlugin as the 4th argument (where there's None in your example). However, the menu entry showed no icon.
      Should this work?


      Opening files in C4D with Python (resolved)

      I should be separating this out into a new Topic I suppose. But any pointers on how to save/open scenes in C4D Python?

      I've tried this:

      import os
      import c4d
      
      
      def file_extensions():
          return [".c4d"]
          
          
      def _document():
          return c4d.documents.GetActiveDocument()
      
      
      def has_unsaved_changes():
          doc = _document()
          if doc:
              return doc.GetChanged()
      
      
      def save_file(filepath):
          doc = _document()
          if doc:
                  return c4d.documents.SaveDocument(doc, 
                                                    filepath, 
                                                    c4d.SAVEDOCUMENTFLAGS_NONE,
                                                    c4d.FORMAT_C4DEXPORT)
      
      
      def open_file(filepath):
          doc = c4d.documents.LoadDocument(filepath, c4d.SCENEFILTER_0, None)
          if doc:
              c4d.documents.SetActiveDocument(doc)
          return doc
      
      
      def current_file():
          doc = _document()
          if doc:
              root = doc.GetDocumentPath()
              fname = doc.GetDocumentName()
              if root and fname:
                  return os.path.join(root, fname)
      

      But whenever I open_file a document and set it active, then all functionality in C4D's UIs gets disabled and greyed out. Am I misinterpreting how this should work? The other code seems to do exactly what I need.

      Edit I should have used c4d.documents.LoadFile for opening a file - that does what I need.

      However, it kept failing with:

      Traceback (most recent call last):
        File "C:\Users\Roy\AppData\Roaming\Maxon\Maxon Cinema 4D R21_64C2B3BD\library\scripts\untitled.py", line 16, in <module>
      doc = c4d.documents.LoadFile(path)
      TypeError:unable to convert unicode to @net.maxon.interface.url-C
      

      This was due to the filepath being unicode. That's fixed by forcing it to str using str(path).

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy
    • Custom menu in C4D top menu bar with custom Python commands

      I'm looking to set up a custom menu in the Cinema4D's top menu bar. I found the Enhancing the Main Menu example which shows how to add a custom menu yet it skips to to show how to add a bunch of custom commands as menu items.

      So basically this is what I found:

      import c4d
      from c4d import gui
        
      
      main_menu = gui.GetMenuResource('M_EDITOR')            
      
      # Create custom menu
      menu = c4d.BaseContainer()
      menu.InsData(c4d.MENURESOURCE_SUBTITLE, "MyMenu")
      
      # Add commands
      menu.InsData(c4d.MENURESOURCE_COMMAND, "IDM_NEU")
      menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)
      menu.InsData(c4d.MENURESOURCE_COMMAND, "IDM_NEU")
      
      # Add custom menu to main menu
      main_menu.InsData(c4d.MENURESOURCE_STRING, menu)
      
      # Refresh menu bar
      gui.UpdateMenus()
      

      Yet now I'm looking to add some menu items that allow me to trigger some custom Python code to show some pipeline tools (Qt widgets). This would be the first step to integrating open-source pipeline Avalon completely into Cinema4D, status for that will be tracked in this Avalon issue.

      1. Say I wanted to add five menu items, each triggering its own tool. How would I do so? I believe I have to register a command and then add it to the menu item. But a quick search didn't bring me to a concrete example on how to do so. I found this topic but it still was unclear how to proceed and make a simple menu item with some custom commands.
      2. Would I need a unique plug-in ID for each single command I'll register? Or can this be done differently?

      A short to the point example could would be much appreciated.

      Thanks in advance! 🙂

      posted in Cinema 4D SDK
      BigRoyB
      BigRoy