Example Index¶
Lists all plugins and scripts that are shipped with the Cinema 4D Python SDK. The examples can also be found on GitHub.
Plugins¶
Command¶
Example |
Description |
Demonstrates a dialog with dynamic content, where the content changes based on user input. |
|
Demonstrates the most basic command/dialog plugin possible. |
|
Demonstrates how to implement a dialog that hosts an HTML viewer and can send and receive data to/from the displayed web page. |
|
Demonstrates how to store dialog layout data and values persistently over dialog open/close and Cinema 4D restart boundaries. |
|
Demonstrates a simple way to store dialog layout data and values persistently over dialog open/close boundaries (but not over Cinema 4D restart boundaries). |
|
Demonstrates a plugin that uses resources to define its dialog layout and string translations. |
|
Demonstrates a simple dialog with two number input fields, a combo box and a button to carry out numeric operations on the two numbers. |
|
Demonstrates implementing a simple legacy memory viewer dialog. |
|
Demonstrates the legacy Sculpting API; it is highly specialized and not that useful outside of sculpting. |
|
Demonstrates implementing a simple legacy texture baking dialog. |
|
Demonstrates a tool finalization workflow at the example of editing SDS weights. |
I/O¶
Example |
Description |
Demonstrates how to implement a scene saver plugin that exports all IES Meta information from the current document to a txt file, iterating through all objects in the scene. |
|
Demonstrates a scene loader plugin for IES Meta data. |
|
Demonstrates how to implement a custom bitmap loader to import a custom picture format into Cinema 4D. |
|
Demonstrates how to implement a custom bitmap saver to export a custom picture format into Cinema 4D. |
Miscellaneous¶
Example |
Description |
Demonstrates how to implement licensing checks in plugins. |
|
Demonstrates simple licensing workflow for Python plugins in Cinema 4D. |
|
Demonstrates how to build custom menus for your plugins. |
|
Demonstrates legacy falloffs, a technology that has been replaced by fields in R20. |
|
Demonstrates how to implement a preference category in the Cinema 4D preference dialog, exposing parameters as global preferences. |
|
Demonstrates how to register two Tokens, one visible in the render settings and the other not. |
Objects¶
Example |
Description |
Demonstrates NodeData serialization and custom branching. |
|
Demonstrates how to implement a scene element that dynamically updates its icon. |
|
Demonstrates how to implement a spline object generator with handles to drive parameters. |
|
Demonstrates how to implement a node (at the example of an object) that dynamically updates its parameters. |
|
Demonstrates how to implement a classic particle modifier object that applies a simple gravitation effect for each particle. |
|
Demonstrates how to implement a scene element respecting OpenColorIO color management. |
|
Demonstrates a spline offset generator (very questionable design, should not be followed). |
|
Demonstrates how to implement a polygonal object generator with handles to drive parameters. |
|
Demonstrates how to implement a modifier object that modifies a point object using the pull sculpting brush tool. |
|
Demonstrates how to implement a deformer object that pushes the points of a point object to a spherical shape, driven by radius and strength parameters. |
Shaders¶
Example |
Description |
Demonstrates how to implement a shader that computes a fresnel effect. |
Tags¶
Example |
Description |
Demonstrates how to implement a tag that forces the host object to look at the camera (like the Look At Camera Tag). |
Tools¶
Example |
Description |
Demonstrates how to implement a simple tool. |
|
Demonstrates how to implement a brush tool that modifies a BaseObject by grabbing all points under the brush. |
|
Demonstrates how to implement a brush tool that rasterizes the stencil onto the polygons touched by the brush, accessing the stencil and BodyPaint layer. |
|
Demonstrates how to implement a brush tool that modifies a BaseObject by pulling all points under the brush. |
|
Demonstrates how to implement a brush tool that modifies a BaseObject by twisting all points under the brush. |
|
Demonstrates how to implement a ToolData with a linkBox where it’s possible to drag and drop an object, which is then cloned and added to the document in a random position. |
Scripts¶
Animation¶
Example |
Description |
Checks the interpolation of the first key for an object’s rotation track. If the interpolation is linear (SLERP) it is changed to cubic. |
|
Loops through all the tracks of the active Motion Tracker object. |
|
Checks the rotation tracks of the active object. |
|
Checks if the active object uses quaternion interpolation. |
|
Synchronizes the keys for the tracks of the active cube’s “Size” parameter. |
|
Reads the vector components curves of the active object’s rotation track curve. |
|
Reads the vector components tracks of the active object’s position track curve. |
|
Creates a FieldList with a formula layer, a mask and another formula layer used as a mask of the first formula layer. Assigns this FieldList to the active object that have a c4d.FIELDS parameter e.g. all MoGraph effectors. |
|
Samples arbitrary points from multiple fields with c4d.FieldList and stores the result into a vertex color tag. |
|
Samples arbitrary points within a random field. |
|
Retrieves all selected clones of the active Cloner object. |
|
Retrieves the weights from all clones of the active Cloner object. |
|
Retrieves the color or each clone using two ways. First one by accessing directly the Mograph Data. Second one by accessing the polygon cache representation of the Mograph Cloner. |
|
Generates and sets a MoGraph selection tag on a MoGraph cloner object. Effectively, this will create a selection tag for all uneven clones in the cloner object. This script has no runtime requirements, as it creates its inputs itself. |
|
Sets a weight of 1.0 for all clones of the active Cloner object. |
|
Demonstrates how to read particle data from a ParticleGroupObject. |
|
Creates 90 Thinking Particles. Defines custom position and color for each particle. |
|
Creates and define a noise shader as an input of a Voronoi Fracture object. |
|
Copies the position, rotation and animation Tracks (so all Keyframes) from obj1 to obj2. |
|
Creates position Y tracks. Adds two keyframes. Sets their value and interpolation. |
|
Checks if the rotation track of an object is synchronized. If not, it will be synchronized. |
Data¶
Example |
Description |
Demonstrates the usage of the central bitmap type. |
|
Demonstrates the usage of the fundamental container type in the Cinema API. |
|
Demonstrates important functions for the types c4d.DescID and c4d.DescLevel. |
|
Demonstrates important functions for the type c4d.Description. |
|
Demonstrates instantiation and usage of various Maxon data types. |
|
Demonstrates the key functionalities of maxon.DataDictionary. |
|
Creates a Maxon Tuple of 3 fields (any maxon type is working). |
Gui¶
Example |
Description |
Creates a Modal Dialog asking for an integer or a float. Retrieves the entered value, once the user exit the Dialog. |
|
Creates an async Dialog with a top menu. Defines an icon in the menu to toggle group visibility. |
|
Creates a basic Modal Dialog. |
|
Creates a Modal Dialog displaying a different SubDialog according to the selected entry of the QuickTab. Demonstrates how to add, flushes, remove tab interactively. |
|
Creates and attaches a SubDialog to a Dialog. Switch the displayed SubDialog after a click on a button. |
|
Example to customize the icon used for a script. The icon should be named like the .py file. Should be a TIF with a size of 32x32. |
|
Example to customize the name and the description in the script manager. Name-en-US defines the displayed name. Description-en-US defines the description of the script. As long as Name-en-US (Prior R20 it was Name-US) and Description-en-US (Prior R20 it was Description-US) are in the first comment bloc, c4d will extract them. |
|
Creates and attaches a GeUserArea to a Dialog. Interacts from the GeDialog to the GeUserArea and vice-versa. |
|
Creates and attaches a GeUserArea to a Dialog. Creates a series of aligned squares, that can be dragged and swapped together. |
I/O¶
Example |
Description |
Provides examples for handling asset databases and repositories. |
|
Provides examples for reading and writing asset metadata. |
|
Provides examples for creating and loading different asset types. |
|
Adds an overlay color to a Picture. |
|
Initializes a bitmap from a vector image file. |
|
Exports Alembic with custom settings. |
|
Exports Obj with custom settings. |
|
Copies the internal data of a 32 bit per-channel image to a new one. |
|
Imports Obj with custom settings. |
|
Imports Sketchup File with custom settings. |
|
Imports STP/STEP with custom settings. |
|
Writes/Reads a bitmap to/from memory. |
|
Writes/Reads simple data to/from memory. |
|
Sets and gets global texture paths (Preferences->Files->Paths). |
Math¶
Example |
Description |
Demonstrates ray casting. |
|
Demonstrates how to use KDTree to find neighboring points in a mesh. |
|
Demonstrates working with matrices. |
|
Demonstrates working with noise functions. |
|
Demonstrates working with quaternions. |
|
Demonstrates working with vectors. |
|
Demonstrates deterministic random values with mxutils.Random. |
Misc¶
Example |
Description |
Demonstrates type and iterable validation with mxutils. |
|
Demonstrates mxutils helpers for diagnosing Cinema 4D scene data. |
|
Demonstrates mxutils helpers for diagnosing Cinema 4D scene data. |
|
Demonstrates importing a package relative to a saved Python script. |
|
Demonstrates translating Cinema 4D symbols with SymbolTranslationCache. |
|
Create a new temporary script. Load an existing Python file into the Script Manager. Retrieve the first script not active in the Script Manager and make it active. |
Modeling¶
Example |
Description |
Explains the geometry model of the Cinema API in Cinema 4D. |
|
Demonstrates handling edges in polygon objects at the example of splitting edges. |
|
Demonstrates how to modify polygonal geometry at the example of extruding polygons. |
|
Demonstrates how to deform points of a point object at the example of ‘flattening’ the selected polygons in a polygon object. |
|
Explains the user-editable polygon object model of the Cinema API. |
|
Demonstrates how to read and write data of an SDS weight tag. |
|
Explains the user-editable spline object model of the Cinema API. |
|
Demonstrates how to ‘transfer’ the axis of a point object to another object while keeping its vertices in place. |
|
Demonstrates creating and configuring LOD objects. |
|
Demonstrates how to execute the ‘Bridge’ tool. |
|
Demonstrates how to execute the ‘Current State to Object’ tool. |
|
Demonstrates how to execute the ‘Edge Smooth’ tool. |
|
Demonstrates how to use the SendModelingCommand (SMC) function in general at the example of the ‘Extrude’ tool. |
|
Demonstrates how to execute the ‘Flatten’ tool. |
|
Demonstrates how to execute the ‘Join’ tool. |
|
Script creates a NormalTag for a selected polygon object with a phong tag where the normals have been rotated by 45° around the world z-axis. Showcases read and write operations for the normals of a NormalTag. Normals are stored for each vertex of each polygon. Raw data normal structure for one polygon is 12 int16 value (4 vectors for each vertex of a Cpolygon * 3 components for each vector), even if the Cpolygon is a triangle. |
|
Creates a new PolygonReduction object. |
|
Reduces the active PolygonObject to the given edge count. |
|
Configures the given PolygonReduction object. Reduces the given PolygonObject to 25%. |
|
Copyright: MAXON Computer GmbH Author: Yannick Puech |
|
Reduces the active PolygonObject to the given vertex count. |
|
Enables the snap if it’s not already the case. Sets it to 3D Type and also to Point mode. |
|
Enables the quantize if it’s not already the case. Defines quantize Move and Scale step. |
|
Retrieves the current workplane position and object. Locks this workplane so it can’t be edited. |
|
Calls BodyPaint 3D UV commands. |
|
Explains how to generate UVW data for polygon objects. |
|
Removes the polygon point selection to the uv points pinned. |
|
Sets the polygon point selection to the uv points pinned. |
|
Adds the polygon point selection to the uv points pinned. |
|
Copies the UV seams to the edge polygon selection. |
|
Gets and Sets Vertex Colors in Point mode: Changes all black Vertex Colors to red. |
|
Gets and Sets Vertex Colors in Polygon mode: Changes all vertex colors to red. |
|
Converts a Polygon Object to a Volume. Does a boolean operation over two Volume objects. Converts the resulting volume into a Polygon Object. |
|
Retrieves a volume object from a volume builder. |
|
Creates a volume builder and adds a cube object to it. Configures cube’s object settings. |
|
Creates a volume builder and inserts it into the active document. |
|
Iterates over all input of a Volume Builder. |
|
Creates a sphere volume with the corresponding command. |
|
Creates a volume from the selected spline object. |
|
Creates a new vector volume object with a curl filter applied from an existing Volume Builder set as vector mode. |
|
Convert a Polygon Object to a Volume and save this volume to a VDB File Save a VDB file. |
|
Create a Spherical Volume filled with gradient data. |
|
Reads the Float value of the first channel available from a Volume stored in a Volume Builder. |
|
Create a volume from scratch and assign values to voxels. |
|
Loads a VDB file to a c4d.VolumeObject. |
|
Convert a Polygon Object to a Volume and convert it back to a Polygon Object |
|
Converts a Polygon Object to a FOG Volume. Does a mix operation over two FOG Volume objects. Converts the resulting FOG volume into a Polygon Object. |
|
Creates 2 vector volume from scratch. Mixes both vector volumes with a cross product to produce a third vector volume. Inserts all 3 volumes into the scene. |
|
Asks for a VDB file to load into a VolumeRef (a VolumeInterface Reference). Insert this VolumeRef into a VolumeObject. Inserts this VolumeObject into the current scene. |
|
Creates a vector volume from scratch. Converts this vector volume to a fog volume. Inserts this fog volume as a child of a volume mesher. |
Nodes¶
Example |
Description |
Demonstrates how graph descriptions create and modify node graphs. |
|
Demonstrates graph description commands. |
|
Demonstrates graph description queries, including lazy color and vector literals. |
|
Demonstrates graph description references together with lazy color and URL literals. |
|
Demonstrates how to associate nodes in a Maxon API graph with their corresponding Cinema 4D API surrogate elements. |
|
Demonstrates creating or getting node graphs in a scene. |
|
Demonstrates the inner structure of node graphs and how to find entities in them. |
|
Retrieve the selected node material and group the node that are selected. |
|
Retrieve information about the selected port of a selected material. |
|
Demonstrates accessing node materials and their graph contents in a scene. |
|
Demonstrates setting up a Redshift node material composed out of multiple nodes. |
|
Demonstrates setting up a Standard renderer node material composed out of multiple nodes. |
|
Create a material for the standard node space and modify the value of the BDSF color port. |
|
This example shows how to select different elements on a node graph. It creates a node material, select ports, print connections and select wires. |
|
This example shows how to solo a node. It creates a material and solo’s the end node in this material. |
|
Retrieve the selected node material and toggle-mute the selected connection, i.e., if the connection is muted, it will be unmuted or vice-versa. A connection is composed out of eight wires, to mute the connection, one must set the INHIBIT wire to WIRE_MODE.NORMAL. To unmute the connection, one must set the INHIBIT wire to WIRE_MODE.REMOVE. |
|
Creates a Constants and Results node in the Xpresso Tag of the selected object. Connects both Nodes together. |
|
Deletes the first node created from the Xpresso Tag of the selected object. |
|
Retrieves the Node Master (The BaseList2D object that holds all nodes) from an Xpresso Tag. |
|
Loops through all nodes from the Xpresso Tag of the selected object. Checks if it’s a Constant Node. |
|
Moves the first node in the Graph View created from the Xpresso Tag of the selected object. |
Plugins¶
Example |
Description |
Provides an example for how one could realize a string encoding pipeline for plugin resources. |
Rendering¶
Example |
Description |
No short description provided. |
|
Demonstrates to manipulate the file outputs of a batch render post process once the rendering has finished. |
|
Demonstrates how to pre-process multiple documents before adding them to the batch renderer for rendering. |
|
Demonstrates how to read, write, and convert colors in an OpenColorIO (OCIO) color-managed document in Cinema 4D. |
|
Demonstrates the details and manual handling of a programmatic rendering process. |
|
Demonstrates how carry out a ‘hardware preview’ rendering, i.e., a rendering of what is shown in the viewport using the hardware renderer. |
|
Configures OpenEXR output render format with SetImageSettingsDictionary() then reads these with GetImageSettingsDictionary(). |
|
Demonstrates how to render document from or at a given frame after prerolling it. |
|
Demonstrates how to manipulate the render settings of a rendering, specifically also the used render engine. |
|
Demonstrates a simple way to programmatically render a document to either memory or disk. |
|
Demonstrates how to render a document split into tiles which can be composited back together to a full image. |
|
Renders a BaseDocument and saves the resulting image using a filename handling tokens. |
Scene¶
Example |
Description |
Demonstrates important functions for the type c4d.C4DAtom. |
|
Demonstrates important functions for the type c4d.BaseList2D. |
|
Demonstrates important functions for the type c4d.GeListNode. |
|
Demonstrates basic document operations. |
|
Demonstrates how to assign a scene element to a layer. |
|
Demonstrates basic operations on objects. |
|
Demonstrates different ways to access and modify parameters of Cinema 4D scene elements. |
|
Demonstrates the fundamental operations of the Take System. |
|
Demonstrates scene traversal. |
|
Demonstrates adding undo steps for document modifications. |
|
Demonstrates how to work with user data parameters. |