Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Is it possible to programmatically create a palette with commands that I specify? I would like to be able to create palettes on demand with certain commands so that a user can dock them.
Hello @kbar,
Thank you for reaching out to us. I am sure you are aware that this has been discussed before and nothing has changed here. It is not possible to programmatically instantiate, open, or populate palettes from the public C++ API. While we technically have the possibility to do it internally, our internal code does not really make use of this either. Which is why such a function does not exist although frequently requested.
There are two options you have:
LoadFile
CommandData
Cheers, Ferdinand
The result:
The script:
"""Loads a palette file into Cinema 4D. Showcases the ability of LoadFile() to handle almost all file formats Cinema 4D can deal with, including layout files for palettes or the whole window. """ import c4d import os def main() -> None: """Loads a palette into Cinema 4D. """ # Determine and assert the palette file path, the palette file in this # example is meant to be located in the same directory as this script. directory = os.path.dirname(__file__) paletteFile = os.path.join(directory, "myPalette.l4d") if not os.path.exists(paletteFile ): raise OSError(f"The path {paletteFile } does not exist.") # Open the palette with LoadFile(). c4d.documents.LoadFile(paletteFile) if __name__ == '__main__': main()