Open BigRoy opened 4 years ago
When Cinema 4D starts, it finds all files in this folder that end with
.pyp
or.pypv
and executes the plugin. A simple plugin possible thus looks like this:
def main():
print "Hello World!"
main()
As such, this can definitely be used to run code at startup.
The plugin can be contained inside Avalon and pointed to with C4D_PLUGINS_DIR
This C4D_PLUGINS_DIR
seems to have been removed since R20 and replaced with g_additionalModulePath
as mentioned here and its usage described here
Posted a question regarding adding a Custom Menu with Custom Python Commands to Cinema4D's top menu bar on the Maxon forums as the Enhance Main Menu example left out how to register custom Python commands and add them to the menu.
Useful links for future reference:
Found an odd bug with Cinema4d where Python scripting gets broken, this is noticable in Extensions > Scripts Manager... (Shift + F11) where the Execute button remains disabled.
The command line log shows:
WARNING: no python vm found [main.cpp(547)]
It seems to happen whenever an empty value is in the PYTHONPATH
path separated values, as described here:
# good
set PYTHONPATH=
set PYTHONPATH=a;b;c
# bad
set PYTHONPATH=;
set PYTHONPATH=;a;b
set PYTHONPATH=a;;b;c
Found the issue in Cinema4D R21.115 TRIAL (Build RB297076)
This bug is something to be wary of when we would launch it through the Launcher.
Here are some progress previews:
Work Files
Avalon Qt interfaces opening fine
Here's the quick and dirty draft integration: https://github.com/BigRoy/core/commit/99bd8bba34659bfb0a764150478b642464ff6c0d
Note:
g_additionalModulePath
environment variable and set that to {core}/setup/cinema4d
avalon.cinema4d.install
- we might want to move that to be more in line with the other hosts.ls()
implementation yet.save_file
should also still set the active document to that path. Now it does save, but your current scene will still think it's set to the old path.Someone will have to explain me how C4D documents/projects work. Apparently you can have many open at the same time but I just can't find where you can actually switch to another open document/project without closing the one you're working in. (Through the UI that is)
They actually do show in the UI at the bottom of the Window menu item unless you open a document in code with c4d.documents.LoadDocument
instead of c4d.documents.LoadFile
and not explicitly insert the base document with c4d.documents.InsertBaseDocument
. Note that with LoadDocument
the file will also not be active automatically (instead its hidden for you) which you can do with c4d.documents.SetActiveDocument
however that's all redundant when you instead use c4d.documents.LoadFile
.
Still it's confusing. 🗡🐉
save_file should also still set the active document to that path. Now it does save, but your current scene will still think it's set to the old path.
Fixed with https://github.com/BigRoy/core/commit/9dd09ae17aa0acdf1ee585d45f664b703e924e1a
Did some quick investigating into how one could create and prepare instances for publishing. In Maya we use objectSets
as containers of what to output. In Houdini we have "ROP nodes" that point a specific node to export.
UserData tags on a node
For Cinema4D I couldn't find any "selection sets" or "object sets" or "containers" that would allow picking a specific set of nodes for exporting - so that didn't seem like the right way to go. I looked at Layers, but they are exclusive for objects (can't be in two layers at the same time) and are used for rendering too which is an area you wouldn't want any clutter to go.
Then I looked into Tags which seemed pretty nice, however it seems they are always applied to a single node and never shared. Nevertheless that definitely seemed like a nice direction because you can colorize them the way you want, give them a custom icon and there seems to be a "Stub" Tag called "UserData" which would be perfect. You can add custom attributes to the tag that allow the customization per tag we need.
Example:
However the downside is still that it would only allow choosing a specific root note, not specific objects you want to include - but I guess there isn't a simple way to do that in C4D anyway.
UserData tags would be a good way forward.
Or... Inclusion Data on a Null with Inclusion UserData field
Or, a single Null
node could be created for each publish instance that has custom attributes defining the settings. There's a specific inclusion
user data field in Cinema4D that allows to do some sort of Memberships, like an object set or collection. This could be perfect for what we'd need. However, the UI in managing it is somewhat clunky. Additionally I'm not sure how trivial it is for advanced C4D users to find these relationships (e.g. not even sure if you can find it from e.g. the member itself)
Here's the User data field in the Manage User Data interface:
Also, this Topic seems related to UserData In-Exclusion fields in C4D and Python access too.
Another way of creating instances for publishing using "selection sets" was described on Avalon Gitter, linking it here for future reference. Thanks! Here it is in the Maxon Cinema4D documentation on Selection Object
Progress on this Integration will likely slow down on my end because of two reasons:
So if anyone needs this in production feel free to still hit me up, and definitely use the above things as a basis. Regarding Pyblish and pyblish plugins for C4D definitely look in the Pyblish for Cinema4D topic and check in with Andre Anjos as he'll be happy to share details too.
Integrate Avalon with Cinema4D
This issue is about Maxon's Cinema4D and building a cinema4d integration for Avalon.
Cinema4D has grown popular amonst many new small-to-medium sized studios because of its ease-of-use. With that stable user base now growing into larger productions it could be great if Avalon could allow them the stable growth to run animation productions efficiently.
Unlike Blender it seems Cinema4D does have some code related to threading which means it could be slightly more trivial to get things up and running nicely.
Implementation notes
C4D_PLUGINS_DIR
and there's alsoC4D_SCRIPTS_DIR
python_init
. However I'm not sure yet whether you can have multiple and/or set an environment variable to keep it contained inside Avalon. However it seems that Plugins (described above) are actually initialized on C4D start either way so that's likely the road we'll need to take.