Just to confirm - skipping the unwanted entries worked absolutely fine for my needs. And I was able to reproduce the behavior in Cinema4D 2023 too if I created such user data manually and tried to access it. So - no bug or regression, just my limited knowledge.
Posts made by BigRoy
-
RE: Cinema4D 2025 get user data value parameter not accessible?
-
RE: Cinema4D 2025 get user data value parameter not accessible?
Thanks so much - of course, it may very well be that something in Cinema4D may just be generating more user data than I expected to live there. As such, I'll just perfectly ignore any values that couldn't be parsed since in my case I only care about those that I put there from Python to begin with.
Thanks for the quick and thorough reply.
-
Cinema4D 2025 get user data value parameter not accessible?
It seems that triggering this logic in Cinema4D 2025 fails:
for description_id, base_container in obj.GetUserDataContainer(): key = base_container[c4d.DESC_NAME] value = obj[description_id]
Which did not error in Cinema4D 2023 and 2024.
With an error along the lines of:value = obj[description_id] ~~~^^^^^^^^^^^^^^^^ AttributeError: Parameter value not accessible (object unknown in Python)
Source issue reported here
Even though this same logic worked in Cinema4D 2023 and 2024.
Is this a regression, or does my code need updating?Could it be failing on trying to get a value from a Group, e.g. as one created here:
# Create the group group_bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_GROUP) group_bc[c4d.DESC_NAME] = group group_bc[c4d.DESC_SHORT_NAME] = group group_bc[c4d.DESC_TITLEBAR] = True group_bc[c4d.DESC_GUIOPEN] = False group_id = node.AddUserData(group_bc)
If so, how would I detect correctly which user data should be allowed to retrieve the values from?
-
RE: Alembic Export Options Not Working
Just want to confirm here that I'm facing this same issue - only setting the negative state first and then the positive state after seems to make this work. So, thanks for the workaround.
Here's the reported bug on our pipeline: https://github.com/ynput/ayon-cinema4d/issues/6
And this is what fixed it: https://github.com/ynput/ayon-cinema4d/pull/8Looking at 'what' fixes it this most definitely sounds like a bug.
(I tested in Cinema4D 2023.2.2 on Windows 10) -
RE: Import and managing 'merged' Alembic
Hi Ilia, this is great - thanks so much. I was able to get what I needed using the
LoadDocument
it seems. Am I correct in understand that the document it 'opens' is only temporary and I do not have to ensure proper deletion (in memory) of the loaded document once I'm done with it?Other than that - part of my code is currently here. It's more of a "spare time" open-source pipeline development because I don't use Cinema4D myself but am hoping it can become useful for others - so thanks for the details!
-
Merged Alembic Generator object, how to check if it is a camera?
When importing an Alembic it turns the objects into Alembic Generators. How can I, without making the objects editable detect whether the object is a camera or not?
print(op.GetTypeName())
Prints:
Alembic Generator
. -
RE: Register event callbacks for "new file", "open file", "save file" (hooks?)
@m_adam said in Register event callbacks for "new file", "open file", "save file" (hooks?):
Regarding new document, sadly there is no way to hook into that and the best way would be to have a MessageData, list all doc by calling c4d.documents.GetFirstDocument and then iterating them by calling BaseList2D.GetNext(). Since a document is a BaseList2D you can hash them and therefor know if there is a new document.
So that would just be running on a timer then, with the hope that I 'trigger' on it swiftly enough? Doesn't fit my needs so dedicated SceneHooks I can register application wide would be a mad helper for this!
Aside of that - was there still a way to 'add' the python generator object into the scene without it maybe serializing into the saved file? Like have a flag that says "Do not serialize"? (Also, Scene Hooks would still be better)
-
Update Xref filepath without user interaction
I'm looking to update filepath of an Xref via Python without user interaction requiring the "Yes" on a popup dialog.
This works:
xref.SetParameter( c4d.ID_CA_XREF_FILE, filepath, c4d.DESCFLAGS_SET_USERINTERACTION, )
But that basically means I will get this pop-up dialog:
However I want to do this without any user interaction in-between. How can I force the update without requiring the
c4d.DESCFLAGS_SET_USERINTERACTION
flag.How can I update the filepath without the pop-up dialog?
This has come up often before, see here:
- http://developers.maxon.net/forum//post/63608
- https://developers.maxon.net/forum/topic/14319/does-xref-or-xref-simple-are-now-accessible-with-python
- http://developers.maxon.net/forum//post/63554
But from back in 2020 through 2022 these remained lingering with "impossible". But hey, the future is bright and now. How do we do this? (From Python)
-
RE: Register event callbacks for "new file", "open file", "save file" (hooks?)
And of course just after I find this Python API: Document Events topic which seems to hit close to this.
However - it seems it requires me to create an ACTUAL object in the scene if I understand correctly - which seems odd. Is there any way that I can make this work - inside the scene file within the pipeline, but have the Cinema4D file itself remain free of this when saved and shared with someone else? (Maybe we can exclude the node from persisting with the scene on saves, or alike?)
Also, that does not allow me to respond to a "new" document being created?
-
Register event callbacks for "new file", "open file", "save file" (hooks?)
I'm looking for a way via Cinema4D's Python API to respond to a user creating a new document (to e.g. apply certain default settings) and to respond to file open and file save (preferably a callback before save and after save) to respond with some custom pipeline logic as well.
A google search and search over the SDK didn't get me anywhere. I did see Plugin Messages and Hooks but both didn't point me in the right direction to run python code on any of the mentioned events. At some point I thought
MessageData
was what I was looking for, but I couldn't find what ids it could capture and whether any were related to new document, saving document, opening documents, etc. -
Import and managing 'merged' Alembic
Hi everyone,
I'm trying to import an Alembic and then afterwards manage the loaded data (like being able to update versions) via Python. However, I'm already stuck at triggering the "Import Alembic" logic without user interventions (no dialogs). How would I do so?
- How to trigger "import alembic" and return the newly created objects?
- To update the alembics after I'm thinking of updating the filepaths on the Alembic paths, and removing any shapes that do not exist anymore in the alembic and creating new ones. Is there an Alembic API that comes with Cinema4D that allows me to query the contents of the alembic?
- I'd like to also update the "visibility" on updates - do I need to 'key' those, or is it capable of streaming those in? Since the checkbox appears to remain disabled for me?
Code snippet, documentation or links are greatly appreciated!
Note: I'm not familiar with Cinema4D - I'm only trying to tackle the pipeline aspect of it for an open-source pipeline called AYON. So even for simple concepts it'd be nice to get the 'dummy" info about it.
I'm looking to do this in 2023.2.2 and up.
-
RE: Custom menu in C4D top menu bar with custom Python commands
@r_gigante Thanks, the command examples were exactly what I needed. And someone stating explicitly that I needed to create a command per menu entry made me help realize that too.
I now have an Avalon menu - perfect.
Bug with C4D and PYTHONPATH
I did hit a C4D bug as I started setting up the pipeline integration, whenever there's an empty value in the list on
PYTHONPATH
then Python fails to run correctly in Cinema4D. More details hereIcons. Are they
.tiff
only?I've tried to add an icon to the menu but I failed there. I tried to pass it a
.svg
icon like so:bitmap = c4d.bitmaps.BaseBitmap() bitmap.InitWith(path)
And then providing that to
c4d.plugins.RegisterCommandPlugin
as the 4th argument (where there'sNone
in your example). However, the menu entry showed no icon.
Should this work?
Opening files in C4D with Python (resolved)
I should be separating this out into a new Topic I suppose. But any pointers on how to save/open scenes in C4D Python?
I've tried this:
import os import c4d def file_extensions(): return [".c4d"] def _document(): return c4d.documents.GetActiveDocument() def has_unsaved_changes(): doc = _document() if doc: return doc.GetChanged() def save_file(filepath): doc = _document() if doc: return c4d.documents.SaveDocument(doc, filepath, c4d.SAVEDOCUMENTFLAGS_NONE, c4d.FORMAT_C4DEXPORT) def open_file(filepath): doc = c4d.documents.LoadDocument(filepath, c4d.SCENEFILTER_0, None) if doc: c4d.documents.SetActiveDocument(doc) return doc def current_file(): doc = _document() if doc: root = doc.GetDocumentPath() fname = doc.GetDocumentName() if root and fname: return os.path.join(root, fname)
But whenever I
open_file
a document and set it active, then all functionality in C4D's UIs gets disabled and greyed out. Am I misinterpreting how this should work? The other code seems to do exactly what I need.Edit I should have used
c4d.documents.LoadFile
for opening a file - that does what I need.However, it kept failing with:
Traceback (most recent call last): File "C:\Users\Roy\AppData\Roaming\Maxon\Maxon Cinema 4D R21_64C2B3BD\library\scripts\untitled.py", line 16, in <module> doc = c4d.documents.LoadFile(path) TypeError:unable to convert unicode to @net.maxon.interface.url-C
This was due to the filepath being
unicode
. That's fixed by forcing it tostr
usingstr(path)
. -
Custom menu in C4D top menu bar with custom Python commands
I'm looking to set up a custom menu in the Cinema4D's top menu bar. I found the Enhancing the Main Menu example which shows how to add a custom menu yet it skips to to show how to add a bunch of custom commands as menu items.
So basically this is what I found:
import c4d from c4d import gui main_menu = gui.GetMenuResource('M_EDITOR') # Create custom menu menu = c4d.BaseContainer() menu.InsData(c4d.MENURESOURCE_SUBTITLE, "MyMenu") # Add commands menu.InsData(c4d.MENURESOURCE_COMMAND, "IDM_NEU") menu.InsData(c4d.MENURESOURCE_SEPERATOR, True) menu.InsData(c4d.MENURESOURCE_COMMAND, "IDM_NEU") # Add custom menu to main menu main_menu.InsData(c4d.MENURESOURCE_STRING, menu) # Refresh menu bar gui.UpdateMenus()
Yet now I'm looking to add some menu items that allow me to trigger some custom Python code to show some pipeline tools (Qt widgets). This would be the first step to integrating open-source pipeline Avalon completely into Cinema4D, status for that will be tracked in this Avalon issue.
- Say I wanted to add five menu items, each triggering its own tool. How would I do so? I believe I have to register a command and then add it to the menu item. But a quick search didn't bring me to a concrete example on how to do so. I found this topic but it still was unclear how to proceed and make a simple menu item with some custom commands.
- Would I need a unique plug-in ID for each single command I'll register? Or can this be done differently?
A short to the point example could would be much appreciated.
Thanks in advance!