Shotgun Toolkit Engine for Maxon Cinema 4D

Hello everyone!

I’ve released my first engine for Maxon Cinema 4D:
tk-cinema repository

I’m not a professional programmer, so some code might be not very nice.

Huge thanks for contribution of @Diego_Garcia_Huerta in shotgun opensource tools. It was big start point for learning hierarchy of shotgun engines and apps.

I’ve tested it only in Windows 10 and only started from version R20 (in R19 there aren’t some critical python functions for solid work of all functions), but it should work on Mac OS too, and it already showed good quality in production (with some studio tweaks around base functionality). Feedback and contributions will be good to improve engine. All hooks for all default tk-apps are included. You might need to modify/tweak the hooks to fit your pipelines/workflows requirements.

I’ve used Diego’s great config and setup guide, just modify all necessary for Cinema.

In my github repository you can find useful apps for Cinema, like tk-cinema-playblast (based on maya version) and few other things, but they are WIP, and need some cleanups and optimizations.

Hope this will help someone!

Cheers!

14 Likes

Thats awesome @Mykhailo_Datsyk, thanks for sharing it here!!

3 Likes

Fantastic work @Mykhailo_Datsyk , the more the merrier!
Not that I know much about C4D, but I gave it a try the other day and managed to work and publish files as expected. I certainly felt a bit of a Déjà vu when I was following the documentation to set things up :slight_smile:

4 Likes

This is awesome, @Mykhailo_Datsyk! Just wanted to let you know that I’ve added it to our Community Shared Integrations page. Thanks for sharing your work with the community!

3 Likes

Thanks @Mykhailo_Datsyk and @Diego_Garcia_Huerta I followed the isntructions but is giving me and error:

2020-02-21 16:54:50,964 [ ERROR] [PROXY] Error calling __commands::cinema_4d((), {}):
Traceback (most recent call last):
File “Z:\XXX\MAT_Shotgun\install\app_store\tk-desktop\v2.4.14\python\tk_desktop\desktop_engine_project_implementation.py”, line 164, in _trigger_callback
callback(*args, **kwargs)
File “Z:\XXX_Shotgun\MAT_Shotgun\install\core\python\tank\platform\engine.py”, line 1082, in callback_wrapper
return callback(*args, **kwargs)
File “Z:\XXX_Shotgun\MAT_Shotgun\install\app_store\tk-multi-launchapp\v0.11.1\python\tk_multi_launchapp\base_launcher.py”, line 123, in launch_version
menu_name, app_engine, app_path, app_args, version, *args, **kwargs
File “Z:\XXX_Shotgun\MAT_Shotgun\install\app_store\tk-multi-launchapp\v0.11.1\python\tk_multi_launchapp\base_launcher.py”, line 373, in _launch_callback
file_to_open,
File “Z:\XXX_Shotgun\MAT_Shotgun\install\app_store\tk-multi-launchapp\v0.11.1\python\tk_multi_launchapp\base_launcher.py”, line 171, in _launch_app
app_engine, app_path, app_args, context, file_to_open
File “Z:\XXX_Shotgun\MAT_Shotgun\install\app_store\tk-multi-launchapp\v0.11.1\python\tk_multi_launchapp\prepare_apps.py”, line 45, in prepare_launch_for_engine
tk_app.sgtk, context, engine_name
File “Z:\XXX_Shotgun\MAT_Shotgun\install\core\python\tank\platform\software_launcher.py”, line 90, in create_engine_launcher
% (engine_name, engine_descriptor)
TankError: Cannot create tk-cinema software launcher! tk-cinema v1.0.0 does not exist on disk.

What I’m missing? I merged all the yml files and copied the tk-cinema (wihout the config folder) inside Install>app_store

Many thanks for your hard work!

2 Likes

I think it looks like you need to run tank cache_apps, in order to actually pull down the bundles you configured.
Hopefully that fixes it!

2 Likes

Many thanks @philip.scadding !
All ok with your idea!
Many thanks!

2 Likes

Hi
Is this Toolkit working with Cinema 4d 21 and 22 ?
Best Kamil

1 Like

Hey @KamilAT — not sure as the original post from back in Jan says R20. Might be worth a quick test if your able.

@Mykhailo_Datsyk—do you know if this works with newer Cinema 4D versions?

Hey @KamilAT, Not sure about R22(not tested yet), but in R21 everything works fine.

2 Likes

Hi Guys
I try to configure this with Cinema 4D 21…207 and shotgun.
I done every step from readme. When I run C4D from Shotgun plugin not started with error:

Traceback (most recent call last):
File “V:\temp\testpipe_config\install\github\mikedatsik\tk-cinema\v1.0.0\startup\shotgun.pyp”, line 179, in
register_plugins()
File “V:\temp\testpipe_config\install\github\mikedatsik\tk-cinema\v1.0.0\startup\shotgun.pyp”, line 167, in register_plugins
for item in engine.import_module(“tk_cinema”).constant_apps.menu_prebuild:
AttributeError:‘NoneType’ object has no attribute ‘import_module’

Any Tips ?

1 Like

It’s working in R21 for me. Has anyone had any luck with adding in other apps/tools? I don’t really understand how to do that in C4D, it’s plugin system is fairly opaque to the newbie.

I have a number of tools I’d normally add into C4D via Shotgun and did so with a different C4D integration prior to our use of R21 (in which it doesn’t work and so why I’m now using Mykhalio’s integration), but I don’t see how to do that now. I see that I need a plugin ID, and sure I’ve generated one, and I can put that in constant_apps.py, but nothing happens. I don;t see how that ID i’ve generated actually relates to my tool? I guess I’d need to add it somewhere, but then you have IDs for the standard Shotgun stuff (Load, Save etc) and those ID numbers aren’t actually present in Shotgun’s apps or the hooks, so I realy don;t understand how IDs and tools are meant to tie together!

Any help @Mykhailo_Datsyk or anyone else, greatly appreciated! Thanks very much.

1 Like

Hi! When I’ve worked on Cinema Integration I found that I can add only predefined hooks inside Cinema, so I didn’t found the way to reproduce maya or houdini dynamic hooks loading system.
That’s why we need to predefine plugins here:


But this only create link to loaded hooks on startup. Id’s needs to be generated base on name of hook and will be compared here:

If this not enough to understand, you can write to me directly and I will try to make more detail.
Cheers!

3 Likes

Thank you, I had changed shotgun.pyp when I was trying to get the plugin to, work (which turned out to be because my install on R21 didn;t have python for some reason… a re-install fixed that!) and had forgotten to change it back!

2 Likes

Hi , thanks for the plugin, but I’m facing some issue. I can start the C4DR23 from shotgun, but in C4D I cannot see any menu for shotgun. Have any of you any clue how to add the menu into latest C4D? Thanks a lot.

Edit: It is working in C4DR21…

1 Like

Hi Ferdinan,

Cinema switched to Python 3.7 in the latest version so I believe that’s why you’re having issues with the engine.

/Jonas

@Mykhailo_Datsyk do you have any plans to update this for R23? As that would be very helpful indeed! Thanks very much.

1 Like

So I am once again attempting to get this to work in R23. It seems to work fine in R21, but fails in both R22 and R23.

First off I clone tk-cinema-master locally so that I could edit it to do the couple of minor syntax changes to make it Python 3 compatible for R23 - no problem there.

The issue is that when opening R22/23 it fails at the first import sgtk it hits:

ModuleNotFoundError:No module named ‘sgtk’

The weird thing is, this isn’t a problem at all in R21, the exact same code runs just fine, so does anyone know why R22/23 would suddenly fail the sgtk import? I don’t think it’s just a pyhton 3 thing, as C4D only switched to Python 3 in R23, but at the moment this won;t run in R22 for me either, even though logically it should basically be the same as R21 behind the scenes… I’m quite lost on this and would appreciate any guidance!

@Mykhailo_Datsyk I guess you might not be maintaining this since your initial release, but do you have any idea what might be going on here? Thanks very much.

1 Like

OK, some mild progress. I can get round the ‘can’t import’ sgtk bit by specifically adding the python folder within the project to my path. Although I’m not actually sure that this bypass is a good ideas, as I then get these errors instead (again only in R23, R21 is still fine. so I don’t understand whats being dealt with differently between the two):

Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun tk-cinema: Cinema on Windows can deadlock if QtWebEngineWidgets is imported. Setting SHOTGUN_SKIP_QTWEBENGINEWIDGETS_IMPORT=1...
Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun tk-cinema: PySide2 not detected - trying for PySide now...
Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun tk-cinema: PySide not detected - it will be added to the setup now...
PySide2/__init__.py: Unable to import shiboken2 from C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\dlls, C:\Program Files\Shotgun, C:\Users\jhudson\AppData\Roaming\Maxon\python37\libs, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37\libs, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib\site-packages, V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python, C:/Program Files/Shotgun\Python\Lib\site-packages
Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun qt_importer: Requesting Qt4-like interface
PySide2/__init__.py: Unable to import shiboken2 from C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\dlls, C:\Program Files\Shotgun, C:\Users\jhudson\AppData\Roaming\Maxon\python37\libs, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37\libs, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib\site-packages, V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python, C:/Program Files/Shotgun\Python\Lib\site-packages
Fri Feb 26 17:09:09 2021 - Shotgun Error | Cinema engine | Shotgun tk-cinema: Default engine QT definition failed to find QT. This may need to be subclassed.
Traceback (most recent call last):
  File "V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python\tank\platform\engine.py", line 2139, in _define_qt_base
    importer = QtImporter()
  File "V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python\tank\util\qt_importer.py", line 51, in __init__
    ) = self._import_modules(interface_version_requested)
  File "V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python\tank\util\qt_importer.py", line 369, in _import_modules
    pyside = self._import_pyside()
  File "V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python\tank\util\qt_importer.py", line 180, in _import_pyside
    self._to_version_tuple(QtCore.qVersion()),
AttributeError: 'NoneType' object has no attribute 'qVersion'
Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun qt_importer: Requesting Qt5-like interface
PySide2/__init__.py: Unable to import shiboken2 from C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\dlls, C:\Program Files\Shotgun, C:\Users\jhudson\AppData\Roaming\Maxon\python37\libs, C:\Users\jhudson\AppData\Roaming\Maxon\Maxon Cinema 4D R23_DBA5903C\python37\libs, C:\Program Files\Maxon Cinema 4D R23\resource\modules\python\libs\python37.win64.framework\lib\site-packages, V:\pipeline\shotgun\sgtk_configs\c4d_test\install\core\python, C:/Program Files/Shotgun\Python\Lib\site-packages
Fri Feb 26 17:09:09 2021 - Shotgun Debug | Cinema engine | Debug: Shotgun qt_importer: No Qt matching that interface was found.
Traceback (most recent call last):
  File "V:\resource\users\Jon H\PyCharmProjects\tk-cinema-master\startup\shotgun.pyp", line 179, in <module>
register_plugins()
  File "V:\resource\users\Jon H\PyCharmProjects\tk-cinema-master\startup\shotgun.pyp", line 167, in register_plugins
for item in engine.import_module("tk_cinema").constant_apps.menu_prebuild:
AttributeError:'NoneType' object has no attribute 'import_module'

So now it’s complaining about shiboken2 and Qt stuff - any thoughts?

I know I’m not the only person interested in this!

1 Like

Hey @jhudsonFP. I just ran into this myself and have a fork that is working with R23 and Python3.

There were a few slight syntax issues but the biggest issue was that R23 no longer adds paths from PYTHONPATH to your sys.path when Cinema4D launches. This meant that all the paths available in shotgun desktop were being disregarded. I’ve fixed this by manually adding the paths from PYTHONPATH to sys.path in the shotgun.pyp plugin that handles bootstraping tk-cinema. I also added support for C4DPYTHONPATH37 which is a new environment variable they are using to replace PYTHONPATH for R23105+. They reason that PYTHONPATH may have remnants of Python2. I think that’s reasonable but also annoying to drop on all their users!

The other big one was making PySide2 and shiboken2 available. To do so I added Shotgun Desktop’s Python3 site-packages PYTHONPATH and C4DPYTHONPATH37 prior to launch, then add them to sys.path in shotgun.pyp.

I’ve created a pull-request for @Mykhailo_Datsyk repo but if you need to get this into production you can point your engine_location to my repo and the latest commit.

Finally, you need to make sure your config is pulling the latest apps from the app_store and unpin the fork of tk-multi-setframerange in the tk-cinema.yml config file.

Good luck!

2 Likes