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

    Posts made by llealloo

    • RE: OpenUSD (pxr) library in c4d python

      @i_mazlov I noticed that the current version of usd-core supports Python <3.13! In the latest version of C4D (2025.0.2), CPython is 3.11.4 😄

      Which means... In theory, it might be relatively easy to make C4D's native usd-core available to CPython! My fingers are crossed that this message reaches the right person. This would be incredibly helpful to be able to use the native version of USD running in C4D with CPython and not have to touch external libraries.

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: How it works new CalcGradientPixel?

      I am kind of surprised there isn't an easier way to sample a Gradient by a normalized 0-1 position 🤔

      Anyway, thanks @mikeudin for the snippet and @m_adam for the fix

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Thanks so much Ilia!

      I really appreciate you taking a look even though it's technically out of scope.

      A lofty question... Is there any interest among developers there at maxon to expose the usd/pxr library that c4d ships with (albeit internally for USD io) natively within c4d python? That would be a most ideal scenario that I'm sure many folks starting to build pipelines with USD in c4d would love to have... Just thought I'd mention it 😊

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      @Firefly2021 this is amazing! thanks so much!

      I admittedly have not tested installation of this lib on windows, only macOS. I think it very well might be a macOS issue if this is any clue:
      https://github.com/PixarAnimationStudios/OpenUSD/issues/1479

      Quoting from the above issue on github:

      The USD library cannot be loaded twice into the same process on the MacOS (and probably Linux, not tested yet). It does work on Windows.

      This is a continuation of #1341, which was the first problem we ran into. We found an acceptable workaround for the TBB deadlock.

      The new problem is that when the second copy of USD gets loaded into the process, it exits the process with
      FATAL ERROR: [TF_DEBUG_ENVIRONMENT_SYMBOL] multiple symbol definitions
      from line 96 in pxr/base/tf/debug.cpp

      What happens is approximately this:

      • Cinema 4D R23 loads its own USD module, a shared library that links dynamically to libusd_ms.dylib, which does its registration.
      • C4D loads our plugin (shared library), which loads another of our shared libraries that is statically linked to USD
      • The copy of USD in our shared library registers its classes, but then it also triggers the registration in C4D's libusd_ms.dylib a second time, which causes the TF_FATAL_ERROR in debug.cpp.

      This seems to be related to the DYLD load callback that gets registered by InstallDyldCallbacks() in pxr\base\arch\attributes.cpp. The first copy's callback gets called for the second copy that gets loaded into the process.

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Did c4d deadlock when you tried:

      from pxr import Usd

      So very curious. Thanks again for your help!

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Hi @i_mazlov, thanks for your response! Did you try:

      import pxr

      followed by :

      from pxr import Usd

      I was also able to successfully "install" it, but actually loading the Usd module in the pxr lib was what gave me the crash. Thanks so much for putting eyes on this.

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Ideally, the USD/pxr library in use by c4d's native USD import/export io plugin could be loaded and used by c4d python. It is my hope that in a future version of C4D this will be possible 🙏

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Understood! Thanks again for looking into this with me 💜

      Okay, to pip install the usd-core library, you will want to make sure your venv is using Python 3.9 or 3.10. This should also work well with c4d 2023.1.3 which uses its own version of Python 3.9. I do understand that the Python version included as part of the c4d install is potentially modified by maxon, and I am hoping that the pxr library will be compatible as long as the major version matches.

      Also fwiw, the usd-core version of the pxr library is a "core" distribution of USD that doesn't require additional dependencies to be installed; it comes prepackaged for use as a Python API and does not need other things to be installed. The only bit usd-core requires is that the Python version you are pip installing from is >=3.6, <3.11.

      What I have done is setup a venv with Python 3.9, pip installed usd-core, and moved the concomitantly downloaded pxr library into c4d python's supported external library directory. import pxr works, but trying to load the from pxr import Usd results in a deadlock of c4d 2023.1.3, and 2024 (though I am not expecting it to work that well given that 2024 runs Python 3.11 which is not fully supported by usd-core)

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Once again, I think this issue stems from the preexisting USD/pxr library loaded natively in c4d for USD import/export. Likely, it is the TBB dependency getting loaded twice into memory that is crashing c4d on macOS.

      Also as a side note, it should be possible to load this library for use in scripts outside of a plugin, too, in which case the directories I previously mentioned would be the top choice so that c4d automatically adds the library to the python sys.path.

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      Hi Thomas, thanks for the response!

      The previous link mentioned references the docs on external python libraries:
      https://developers.maxon.net/docs/py/2023_2/manuals/introduction/python_libraries.html

      I have been trying to put the pxr library in:
      ~/Library/Preferences/Maxon/python/python39/libs for 2023
      ~/Library/Preferences/Maxon/python/python311/libs for 2024
      (as outlined in the docs)

      I can get the pxr lib to load in python successfully with import pxr, so I know it is seeing the library. The issue is that when I try to load any of the library's modules, it deadlocks c4d.

      It should be fairly easy to reproduce on your end if you grab pxr from usd-core at https://pypi.org/project/usd-core/

      Thanks again for the help!

      Leah

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • RE: OpenUSD (pxr) library in c4d python

      I forgot to mention some further information that might be helpful...

      I am aware the usd-core requires Python >=3.6, <3.11 and that 2024 uses Python 3.11. I have tried loading it in the same fashion with earlier versions of c4d (2023) also with a crash when trying from pxr import Usd

      posted in Cinema 4D SDK
      lleallooL
      llealloo
    • OpenUSD (pxr) library in c4d python

      Hello, I am curious how one might try to load the pxr library in c4d python as part of a plugin? I have loaded the pxr library (from usd-core) into the shared third party python libs directory as mentioned here.

      It seems that there is some conflict (crash) if I try to:
      import pxr
      followed by:
      from pxr import Usd <- this is where the crash occurs.

      I am quite certain this is due to c4d's native (C++) version of USD already being loaded into memory (or one of its dependencies such as TBB). This thread here gives me some clues, but not a solve so far. By the way, I am using macOS. This issue on github also provides more clues.

      Thanks for your help, and I wish everyone a happy 2024!

      Leah

      posted in Cinema 4D SDK python 2024
      lleallooL
      llealloo