• 2024.4.0 SDK Release

    News & Information news cinema 4d c++ python sdk
    7
    2
    1 Votes
    7 Posts
    15k Views
    ferdinandF
    Hey, so, I fixed this now, in the sense that the TOC is now back in these classic API type and module pages. [image: 1713774613887-c2f5944c-90e4-49f9-a194-44f7be96b281-image-resized.png] I renamed the old a bit wordily named "Functions Signatures" and "Functions Documentation" to Overview and Functions (or Methods for classes) . Opposed to the old pre 2024.3 TOCs (which were completely broken in many ways), these categories now also show up in the TOC: [image: 1713775118359-adcc5c03-d5fd-4f97-b206-7d69cef2d81e-image-resized.png] [image: 1713774646259-bc7bac63-8959-487a-8aa7-81e729fcc92a-image-resized.png] The old Types and Inheritance section has been merged into root element as I do not see a good reason why it should appear in the middle of the page. The obvious thing would be to now add links to the individual elements on a page, so that you can quick-jump to a particular function. But that turned out to be not so easy with the mess we made there before and stubborn docutils. As evident by the C4DAtom example and other cases our TOC trees are very broken in this part of the docs and I now already almost spent two days with fixing things to this state. This will be shipped in the current state with the next release of Cinema 4D. When I have some time to waste, I will try to add the function links. The manual and maxon API TOCs are unaffected by this, they continue to work as intended. The classic API does its own thing here (as always ) which why this is such a mess. Cheers, Ferdinand
  • Copy children to selection with GetClone()

    Cinema 4D SDK python 2024
    3
    0 Votes
    3 Posts
    849 Views
    John_DoJ
    Hi @ferdinand, thanks for the feedback, I've got it working with your suggestion. The method B was correct but the undo part was wrong ( the undo step was applied on the original objects instead of the new ones, thus leading to a mess when performing an undo). I also added the bit part to keep new objects folded in the OM. Here is the code : # CopyDeformers import c4d doc = c4d.documents.GetActiveDocument() def main(): doc.StartUndo() objs = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER) if len(objs) >= 2: # Get the last selected object active = objs.pop(-1) # Get the deformers deformers = [i for i in active.GetChildren()] # Copy deformers to selection if deformers: for o in objs: for d in deformers[::-1]: dcopy = d.GetClone(c4d.COPYFLAGS_NO_BITS) doc.InsertObject(dcopy, parent=o) doc.AddUndo(c4d.UNDOTYPE_NEW, dcopy) o.SetBit(c4d.BIT_MFOLD) doc.EndUndo() c4d.EventAdd() if __name__ == '__main__': main()
  • fieldlayer with variable tag

    Cinema 4D SDK windows python 2023
    2
    1
    0 Votes
    2 Posts
    594 Views
    D
    found the solution ... the corresponding type is called: FLweight
  • 0 Votes
    2 Posts
    890 Views
    ferdinandF
    Hello @seora, Thank you for reaching out to us. There is noch such functionality to encrypt Python scripting elements. You can encrypt Python plugins, but not things like a Python tag or generator object. I have moved this thread since its is not about the Python API but a feature of Cinema 4D. Cheers, Ferdiand
  • How to LoadDocument from string in memory? 🤔

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    1k Views
    mikeudinM
    Cool! Thank you!
  • 0 Votes
    2 Posts
    643 Views
    ferdinandF
    Hey @BretBays, Thank you for reaching out to us. You might want to have a look at the Python Libraries Manual. Since Cinema 4D 2024.0 there is also mxutils.LocalImportPath which automates injecting module paths and reloading such imported modules (I probably should update the Python libraries manual). The "flaw" of all these approaches is that while you still encrypt your plugins pyp file, the imported module(s) py file(s) will not and cannot be encrypted. You can either ship your common functions unencrypted or develop your plugin as a multi module solution (so that you do not have to replicate your code across plugins) and then package up the plugin into a singular file. There are some Python tools like pysconcat and pymerger which can help you with that. But you should be aware that these can fail when you have complex dependencies. You could also serve the py-cache of your modules, but that will not really stop anyone who wants to read your code. Cheers, Ferdinand
  • Create folder in Volume Builder

    Cinema 4D SDK windows python 2023
    3
    0 Votes
    3 Posts
    733 Views
    D
    hi @i_mazlov, thanks for the answer. good to know about this status / limitation. for my current case I found a solution without folders..
  • Plugins Search Path from Preferences

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    893 Views
    merkvilsonM
    Thanks @ferdinand I wrote this little script for those who want to add one plugin path via the C4D script. I will update it later. It will NOT overwrite existing paths. Restart is required for instant result. import c4d import os import json def add_plugin_path(path, restart = False): if os.path.exists(path): new_path = path.replace("\\", "/") else: print("Path does not exists") return prefs_folder = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS) prefs_path = os.path.dirname(prefs_folder) plugins_json_path = os.path.join(prefs_path, 'plugins.json') if os.path.exists(plugins_json_path): with open(plugins_json_path,'r',encoding="utf-8-sig") as plugins: plugins_json_raw = plugins.read() plugins_dict = json.loads(plugins_json_raw) content_dict = plugins_dict["content"]["_impl"]["_data"][1]["content"] # Check if the new path is already in Plugins Path for content_path in content_dict: if os.path.normpath(content_path["_0"]["_path"]) == os.path.normpath(new_path): print(f"'{new_path}' is already in Plugins Path.") return else: plugins_dict = { 'identification': 'plugins', 'content': { 'referenceDataType': 'net.maxon.interface.datadictionary-C', '_impl': { '_mode': 2, '_data': [ { 'dataType': 'net.maxon.datatype.id', 'content': 'searchPaths' }, { 'dataType': '(net.maxon.interface.url-C,bool)', 'isArray': True, 'content': []}]}}} # Create new path content new_content = { "_0": { "referenceIndex": len(plugins_dict["content"]["_impl"]["_data"][1]["content"]), "referenceDataType": "net.maxon.interface.url-C", "_scheme": "file", "_path": new_path, "_authority": {}, "_data": {} }, "_1": True } # Append the new path to the list of paths plugins_dict["content"]["_impl"]["_data"][1]["content"].append(new_content) # Convert the dictionary back to a JSON string updated_plugins_dict = json.dumps(plugins_dict, indent=4) # Write the updated dictionary back to a JSON file with open(plugins_json_path, 'w') as plugins_json: plugins_json.write(updated_plugins_dict) if restart: c4d.RestartMe() custom_path = r"/Path/To/Plugin/Directory/" add_plugin_path(path = custom_path, restart = False)
  • 0 Votes
    3 Posts
    1k Views
    T
    Hi Adam, thanks for the update and the workaround!
  • Get information about renderer plugin via Python

    Moved General Talk 2024 python 2023
    6
    0 Votes
    6 Posts
    2k Views
    ferdinandF
    Hello @hSchoenberger, Sorry, but this is a C4D SDK question! It is NOT about the Octane SDK. "How can I list all installed renderer plugins in C4D with their version?" Although you have put your sentence into quotes, that was not what you asked, your questions were: Is there any way to get some information about renderer plugins? I want to get the version of the Octane plugin. So how I can loop through all plugins loaded and get some information from the plugins like the version? And I answered that: There is no public interface with which you could get the version of a plugin. And when plugins provide version information on their own, you must ask their vendors about that. You can access the flags a plugin has been registered with BasePlugin.GetInfo, the disk-level is in-accessible for you. You can detect installed render engines by looping over all video post data plugins and check if they have PLUGINFLAG_VIDEOPOST_ISRENDERER set (this assumes that the to be detected render engine sets this flag on registration - which is usually unavoidable as you otherwise cannot hook in the render system of Cinema 4D, but there might be 'rogue' render engines out there which side step things). import c4d doc: c4d.documents.BaseDocument # The currently active document. op: c4d.BaseObject | None # The primary selected object in `doc`. Can be `None`. def main() -> None: """Called by Cinema 4D when the script is being executed. """ plugin: c4d.plugins.BasePlugin for plugin in c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_VIDEOPOST, True): if (plugin.GetInfo() & c4d.PLUGINFLAG_VIDEOPOST_ISRENDERER): print (plugin.GetName()) if __name__ == '__main__': main() # Example output for a vanilla installation. Physical Redshift Viewport Renderer Cheers, Ferdinand
  • 0 Votes
    6 Posts
    1k Views
    S
    Okay. I'll ask the support center
  • 0 Votes
    2 Posts
    485 Views
    ferdinandF
    Hey @JACK0319, Thank you for your issue report, I have fixed it and it will be shipped with the next release. Cheers, Ferdinand
  • 0 Votes
    4 Posts
    1k Views
    F
    Thank you, it works perfectly!
  • 0 Votes
    3 Posts
    674 Views
    ferdinandF
    Hey @datamilch, Thank you for reaching out to us and answering your own question. In general we prefer it when topics do not get deleted, so that other users can benefit from a topic. You should also not be able to delete this topic anymore since more than three hours have passed since you posted and because your topic has replies. Cheers, Ferdinand
  • 0 Votes
    5 Posts
    1k Views
    gheyretG
    @czt_306 It looks realy cool!
  • Title in dropdown menu

    Cinema 4D SDK python
    2
    1
    0 Votes
    2 Posts
    915 Views
    i_mazlovI
    Hello @manudin! 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 These static text separators are just normal separators with provided title. You can do this by assigning BaseContainer instead of boolean (please check the code snippet below). Cheers, Ilia import c4d from c4d import gui def EnhanceMainMenu(): menu = c4d.BaseContainer() menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Menu 1") menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Ocube)) menu.InsData(c4d.MENURESOURCE_SEPARATOR, True); menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Osphere)) m = c4d.BaseContainer() m.InsData(c4d.MENURESOURCE_SUBTITLE, "My Category") menu.InsData(c4d.MENURESOURCE_SEPARATOR, m) menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Oplane)) mainMenu = gui.GetMenuResource("M_EDITOR") mainMenu.InsData(c4d.MENURESOURCE_STRING, menu) if c4d.threading.GeIsMainThreadAndNoDrawThread(): c4d.gui.UpdateMenus() if __name__ == "__main__": EnhanceMainMenu()
  • Expose cpp-registered datatype to python

    Cinema 4D SDK c++ python
    4
    0 Votes
    4 Posts
    1k Views
    ferdinandF
    Hey @aghiad322, please re-read my answer I have given above. You implement a custom data type in C++, your SplineVisDataType in splinevis.h. Then you reference that data type in a resource of a Python plugin (SPLINEVIS ANIMATION_CLONER_SPLVIS { ANIM OFF; };). You will not be able to interact with this parameter/data type in Python until you have ported it or use the other approach I have lined out above - decomposition/channels. As also lined out above, you will be never able to get-access a parameter with a custom data type you have implemented yourself in Python because C4DAtom.GetParameter hardcodes the casting/unpacking of data types to Python. Cheers, Ferdinand PS: And if you only want another way to display SplineData, you can also just write a custom GUI targeting that data type. There is no necessity to always write your own custom data type for a custom GUI, you can also target existing ones. You would then have to set the custom GUI to yours when you define a SPLINE element in a dialog or description resource
  • Set value of a fieldlayer parameter

    Cinema 4D SDK windows python 2023
    3
    1
    0 Votes
    3 Posts
    734 Views
    D
    hi @ferdinand, this solved it, thanks! I suspected, that I would have to write back the data, as in many other cases. but I didn't know how exactly. As for the executable code: will do so, next time! cheers Sebastian
  • How to add "scripts" to a menu?

    Cinema 4D SDK 2024 python
    4
    0 Votes
    4 Posts
    2k Views
    ferdinandF
    Hey @mogh, I know that you did not meant any harm and the word hijack was a bit strong - which is why reworded that before you answered. But topics should remain focused on a singular thing, the specific question of the original poster, rather than being a collection of questions from multiple people which roughly align with whatever broader topic they see embodied in a thread. Cheers, Ferdinand
  • Prevent material preview update

    Cinema 4D SDK windows python 2023
    3
    0 Votes
    3 Posts
    1k Views
    D
    hi @ferdinand, thanks for the information. found a workaround, that is good enough so far. I use the 3d-gradient in texture space and transform the texture tag matrix as I need it. the change in color will not occur that often.