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. moghurt
    3. Posts
    • Profile
    • Following 2
    • Followers 0
    • Topics 3
    • Posts 7
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by moghurt

    • How to Execute Pre-Render Python Scripts in Cinema 4D Command Line?

      Hey everyone,

      I would like to know if Cinema 4D supports pre-render and post-render Python script workflows. I use the command line to render files, but unfortunately, I haven't found a suitable method to call a Python script to modify the file before rendering. Here is the rendering command line I use:

      "C:\Program Files\MAXON\CINEMA 4D 2024\CINEMA 4D.exe"-nogui -frame 0 0 1 -render "C:\Renderer\render.c4d" -oresolution "1920" "1080" -oformat "PNG" -oimage "C:\Renderer\output\render"
      

      I tried using the pyp plugin to execute Python scripts when starting the software to modify the project file, but when I use the '-render' parameter, the Python code in the pyp plugin is executed after the rendering is complete. I have read other forum posts, and developers seem to indicate that Python plugins cannot adjust the command line execution priority, and the '-render' parameter always takes precedence. So, the pyp plugin may not be a good solution.

      It seems quite challenging to execute a Python script to modify the file before rendering in the C4D command line. If the '-render' parameter is used, no modifications can be made to the file. Unless the modification is saved directly to the file, but this method is destructive.
      😢 😢 😢

      Feel free to let me know if there are any specific details or changes you'd like to include!

      posted in Cinema 4D SDK windows python 2024 2023 r21 r23 r25
      moghurtM
      moghurt
    • RE: TagData plugin undo issues

      Hi @ferdinand ,
      As per your suggestion I have stored the data in containers and implemented caching, I'm very sorry that I may not have described it clearly enough but the problem is now solved!

      Thanks again for your help, cheers!

      posted in Cinema 4D SDK
      moghurtM
      moghurt
    • RE: TagData plugin undo issues

      @ferdinand
      Hi ferdinand,
      Thank you for your response; it has been very helpful!

      I have implemented different instances for different nodes as suggested. However, I am encountering an issue when undoing actions. My plugin's cached data, which is stored in instance attributes, gets reinitialized upon undo. I would prefer to use a data container to manage this cached data, but I have no experience with data containers.

      Could you provide a simple demo code or direct me to an existing related post?

      Thank you!

      posted in Cinema 4D SDK
      moghurtM
      moghurt
    • TagData plugin undo issues

      When I need to use a class attribute as a cache in a Tag plugin, if I do an undo, the entire Tag plugin reinitializes causing my cached data to be lost!

      When I use global variables to cache data, it will conflict if there are multiple tags in the scene!

      How should I cache data in a tag without it being initialized on undo?

      class MyBase(object):
          def __init__(self):
              self.mycache = None
      
      class MyTag(plugins.TagData):
          def Init(self, node, isCloneInit):
              self.MB = MyBase()
      
      posted in Cinema 4D SDK python windows
      moghurtM
      moghurt
    • RE: Encountering Issues with Generating Hash Suffix for Preferences Directory in C4D

      @m_adam m_adam resolved the issue perfectly. Thanks for the great support!

      posted in Cinema 4D SDK
      moghurtM
      moghurt
    • Encountering Issues with Generating Hash Suffix for Preferences Directory in C4D

      Hello everyone,

      I am experiencing some issues while generating the directory for the Cinema 4D preferences folder. I referenced the code from Maxon's official Github repository, 'cinema4d_py_sdk_extended/scripts/01_foundations/retrieves_temp_folder_r17.py'.
      https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/ba0daf1711ef0065f6587bf08b8aaec6c48dc96f/scripts/01_foundations/retrieves_temp_folder_r17.py

      When I use this method and input the directory 'C:\Program Files\MAXON\Cinema 4D 2023', the result I get is 'C:\Users\Mcyog\AppData\Roaming\MAXON\Cinema 4D 2023_76175CB', where the hash suffix is '76175CB', a 7-digit number. However, the correct result should be '076175CB'.

      I have tried other directories and they all output the correct hash suffix. Only the directory 'C:\Program Files\MAXON\Cinema 4D 2023' has this issue.

      Interestingly, when Cinema 4D automatically generates preferences, it creates the correct 8-digit hash suffix '076175CB' for this directory. I would like to know if the method from Github needs to be updated, and I need a way to retrieve the preferences without starting Cinema 4D, as this seems to be the only solution.
      CRCbug.gif

      Any assistance or insights would be greatly appreciated. Thank you!

      posted in Cinema 4D SDK python
      moghurtM
      moghurt
    • RE: Extending the Command Line with Python

      @jwzegelaar said in Extending the Command Line with Python:

      We found a good workaround! We now made a custom commandline plugin where we can add our own arguments. And it works great. If anybody in the future has this issue you can always contact us and we will help.

      Thanks again everybody for all the help!

      Hi jwzegelaar,
      I believe that I share the same needs as you, where I also need to pass in external parameters via a .py file to make modifications to the file before rendering. Unfortunately, I am encountering the same issue as you.
      Although this post has been quite some time, I am still hopeful for your assistance. Your help would be greatly appreciated and it is highly important to me.

      posted in Cinema 4D SDK
      moghurtM
      moghurt