Cinema 4D Python on Windows Long Path Errors
-
Hi!
We are having trouble handling files with long paths on Windows in Cinema 4D Python. When a full file path exceeds 260 characters, Cinema 4D Python cannot read or write the file. We've encountered this issue with both Cinema 4D Redshift and non-Redshift job.
The easiest way to reproduce this is to open
Windows
->Console
->Python
in Cinema 4D on Windows and run the following command:import os from pathlib import Path p = Path(r"C:\ProgramData" + r"\test1234567890" * 26) os.makedirs(p)
The output we get from this is:
Traceback (most recent call last): File "console", line 1, in <module> File "<frozen os>", line 215, in makedirs File "<frozen os>", line 215, in makedirs File "<frozen os>", line 215, in makedirs [Previous line repeated 7 more times] File "<frozen os>", line 225, in makedirs FileNotFoundError: [WinError 206] The filename or extension is too long: 'C:\\ProgramData\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890'
Similarly, if we try to read an existing file that has a long path:
p = Path(r"C:\ProgramData" + r"\test1234567890" * 26 + r"\test.txt") p.open("r") # same result with p.open("w")
We get an error:
Traceback (most recent call last): File "console", line 1, in <module> File "C:\Program Files\Maxon Cinema 4D 2025\resource\modules\python\libs\win64\lib\pathlib.py", line 1044, in open return io.open(self, mode, buffering, encoding, errors, newline) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'C:\\ProgramData\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test1234567890\\test.txt'
When I run either of these commands in an external Python interpreter (e.g. from https://www.python.org/) on my workstation, I don't get an an error and the directories are created and files are read/written.
Cinema 4D Versions: Tested on 2025.1.2 and 2024.5.1
Windows Version: Windows 11 Enterprise 24H2
Redshift Version: 2025.2.2 -
Hello @joel-wong-aws,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.
About your First Question
There are two factors which impact maximum path lengths for applications which use calls to the Win32 API (see Microsoft Learn: Maximum Path Length Limitation for details). Having set the related registry key and having the application itself support it via its manifest.
Cinema 4D itself does not offer native Win32 overly long path support, i.e., does not set
<ws2:longPathAware>true</ws2:longPathAware>
in its manifest. This is a limitation induced by Redshift. The outcome is, that Cinema 4D supports overly long paths via UNC in its native settings, e.g.,Render Settings/Save/File
. But when you try to paste such overly long path into a Redshift RS Texture node, Cinema 4D will go up in flames.You can imitate that in Python, and use UNC paths for overly long paths:
import os from pathlib import Path # Define an UNC path that exceeds 260 characters and then create it when it does not exist. uncPath: str = str(Path(r"\\?\d:\temp" + r"\ten__chars" * 26)) if not os.path.exists(uncPath): os.makedirs(uncPath) print (f"Created {uncPath = }")
We might be able to add
longPathAware
support for our Python VM (Cinema 4D itself cannot do it, as this would entail errors for Redshift). I do not own the relevant systems, so I cannot really judge how hard that would be to do (@m_adam does). But UNC strikes me as fine, and generally enablinglongPathAware
support for the Python DLL while keeping it for the app disabled also rather risky.Could you outline a scenario where this is absolutely necessary?
Cheers,
Ferdinand -
Hi Ferdinand,
Thank you for your help!
I've briefly tried out the solution you have proposed. I already have the registry key set. I've spent a day trying to get our scripts to work with UNC, but unfortunately haven't been able to complete a successful end to end render. Redshift is also important to us, so long path support there would be valuable in our flows as well.
For context, I am from the AWS Deadline Cloud team and we have written an integration to allow users to run Cinema 4D renders (including Redshift workloads) on our product. The current integration code is publicly available here.
One of the reasons that we encounter long path issues so often is that our assets are stored in a directory like
C:\ProgramData\Amazon\OpenJD\session-d04e4000a1754907bcb75289655c2a8ff_32sm7o\assetroot-7a6a0443639bf42cdffb\
.
We intentionally chose this path to make the organization of assets clearer between different render jobs. However, it can prepend up to ~100 characters to the file path, depending on the user's path mapping.While we are also working within AWS Deadline Cloud to allow the asset directory to be configurable (and potentially shortened), the work isn't trivial and so simply having long paths supported on Cinema 4D Python (and Redshift!) would simplify things a lot for us and our customers.
Unfortunately, I haven't been able to get Cinema 4D working with UNC long paths in our scripts after a day of debugging. Adding UNC everywhere doesn't just make it more complicated for us, but also for any contributors that wish to make changes to the adaptor.
So in short: we don't know of any scenarios where long path support in Cinema 4D Python is absolutely necessary, but it would save us and our users a lot of time and headache. We have projects that exceed the default path limit and would benefit from long path support in Cinema 4D Python and Redshift.
Thanks,
Joel -
Hello everyone,
we have moved this topic to a mail discussion, when there are outcomes relevant for other developers, I will post them here.
Cheers,
Ferdinand