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

py_cmd_gui_dynamic

Demonstrates a dialog with dynamic content, where the content changes based on user input.

py_cmd_gui_hello_world

Demonstrates the most basic command/dialog plugin possible.

py_cmd_gui_html

Demonstrates how to implement a dialog that hosts an HTML viewer and can send and receive data to/from the displayed web page.

py_cmd_gui_persistent

Demonstrates how to store dialog layout data and values persistently over dialog open/close and Cinema 4D restart boundaries.

py_cmd_gui_persistent_no_restart

Demonstrates a simple way to store dialog layout data and values persistently over dialog open/close boundaries (but not over Cinema 4D restart boundaries).

py_cmd_gui_resources

Demonstrates a plugin that uses resources to define its dialog layout and string translations.

py_cmd_gui_simple

Demonstrates a simple dialog with two number input fields, a combo box and a button to carry out numeric operations on the two numbers.

py_cmd_memory_viewer

Demonstrates implementing a simple legacy memory viewer dialog.

py_cmd_sculpt_save_mask

Demonstrates the legacy Sculpting API; it is highly specialized and not that useful outside of sculpting.

py_cmd_texture_baker

Demonstrates implementing a simple legacy texture baking dialog.

py_cmd_tool_finalization

Demonstrates a tool finalization workflow at the example of editing SDS weights.

I/O

Example

Description

py_io_ies_meta

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.

py_io_ies_meta_loader

Demonstrates a scene loader plugin for IES Meta data.

py_io_xample_loader

Demonstrates how to implement a custom bitmap loader to import a custom picture format into Cinema 4D.

py_io_xample_saver

Demonstrates how to implement a custom bitmap saver to export a custom picture format into Cinema 4D.

Miscellaneous

Example

Description

py_msc_licensing

Demonstrates how to implement licensing checks in plugins.

py_msc_licensing_simple

Demonstrates simple licensing workflow for Python plugins in Cinema 4D.

py_msc_menu

Demonstrates how to build custom menus for your plugins.

py_msc_noise_falloff

Demonstrates legacy falloffs, a technology that has been replaced by fields in R20.

py_msc_preference

Demonstrates how to implement a preference category in the Cinema 4D preference dialog, exposing parameters as global preferences.

py_msc_render_token

Demonstrates how to register two Tokens, one visible in the render settings and the other not.

Objects

Example

Description

py_obj_assetcontainer

Demonstrates NodeData serialization and custom branching.

py_obj_custom_icon

Demonstrates how to implement a scene element that dynamically updates its icon.

py_obj_double_circle

Demonstrates how to implement a spline object generator with handles to drive parameters.

py_obj_dynamic_parameters

Demonstrates how to implement a node (at the example of an object) that dynamically updates its parameters.

py_obj_gravitation

Demonstrates how to implement a classic particle modifier object that applies a simple gravitation effect for each particle.

py_obj_ocio_node

Demonstrates how to implement a scene element respecting OpenColorIO color management.

py_obj_offset_y_spline

Demonstrates a spline offset generator (very questionable design, should not be followed).

py_obj_rounded_tube

Demonstrates how to implement a polygonal object generator with handles to drive parameters.

py_obj_sculpt_modifier_deformer

Demonstrates how to implement a modifier object that modifies a point object using the pull sculpting brush tool.

py_obj_sphere_deformer

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

py_sha_fresnel

Demonstrates how to implement a shader that computes a fresnel effect.

Tags

Example

Description

py_tag_look_at_camera

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

py_tool_liquid_painter

Demonstrates how to implement a simple tool.

py_tool_sculpt_grab_brush

Demonstrates how to implement a brush tool that modifies a BaseObject by grabbing all points under the brush.

py_tool_sculpt_paint_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.

py_tool_sculpt_pull_brush

Demonstrates how to implement a brush tool that modifies a BaseObject by pulling all points under the brush.

py_tool_sculpt_twist_brush

Demonstrates how to implement a brush tool that modifies a BaseObject by twisting all points under the brush.

py_tool_ui

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

key_quaternion_interpolation

Checks the interpolation of the first key for an object’s rotation track. If the interpolation is linear (SLERP) it is changed to cubic.

motion_tracker_object_track

Loops through all the tracks of the active Motion Tracker object.

object_find_best_euler_angle

Checks the rotation tracks of the active object.

object_quaternion_rotation

Checks if the active object uses quaternion interpolation.

object_sync_vector_keys

Synchronizes the keys for the tracks of the active cube’s “Size” parameter.

object_vector_curves

Reads the vector components curves of the active object’s rotation track curve.

object_vector_tracks

Reads the vector components tracks of the active object’s position track curve.

field_list_add_mask

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.

field_list_sampling

Samples arbitrary points from multiple fields with c4d.FieldList and stores the result into a vertex color tag.

field_object_sampling

Samples arbitrary points within a random field.

modata_get_selection

Retrieves all selected clones of the active Cloner object.

modata_get_weights

Retrieves the weights from all clones of the active Cloner object.

modata_read_color

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.

modata_set_selection

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.

modata_set_weights

Sets a weight of 1.0 for all clones of the active Cloner object.

particle_group_object

Demonstrates how to read particle data from a ParticleGroupObject.

thinking_particles_creates

Creates 90 Thinking Particles. Defines custom position and color for each particle.

voronoi_fracture

Creates and define a noise shader as an input of a Voronoi Fracture object.

track_copy

Copies the position, rotation and animation Tracks (so all Keyframes) from obj1 to obj2.

track_create_keys

Creates position Y tracks. Adds two keyframes. Sets their value and interpolation.

track_synchronized

Checks if the rotation track of an object is synchronized. If not, it will be synchronized.

Data

Example

Description

_c4d_basebitmap

Demonstrates the usage of the central bitmap type.

_c4d_basecontainer

Demonstrates the usage of the fundamental container type in the Cinema API.

_c4d_descid

Demonstrates important functions for the types c4d.DescID and c4d.DescLevel.

_c4d_description

Demonstrates important functions for the type c4d.Description.

_maxon_basearray

Demonstrates instantiation and usage of various Maxon data types.

_maxon_datadictionary

Demonstrates the key functionalities of maxon.DataDictionary.

_maxon_tuple

Creates a Maxon Tuple of 3 fields (any maxon type is working).

Gui

Example

Description

dialog_ask_number

Creates a Modal Dialog asking for an integer or a float. Retrieves the entered value, once the user exit the Dialog.

dialog_menu_hide_content

Creates an async Dialog with a top menu. Defines an icon in the menu to toggle group visibility.

dialog_modal

Creates a basic Modal Dialog.

dialog_quick_tab

Creates a Modal Dialog displaying a different SubDialog according to the selected entry of the QuickTab. Demonstrates how to add, flushes, remove tab interactively.

dialog_subdialog

Creates and attaches a SubDialog to a Dialog. Switch the displayed SubDialog after a click on a button.

script_icon

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.

script_name_description

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.

user_area_basic

Creates and attaches a GeUserArea to a Dialog. Interacts from the GeDialog to the GeUserArea and vice-versa.

user_area_drag

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

asset_databases

Provides examples for handling asset databases and repositories.

asset_metadata

Provides examples for reading and writing asset metadata.

asset_types

Provides examples for creating and loading different asset types.

bitmap_fill_color

Adds an overlay color to a Picture.

bitmap_init_vector_file

Initializes a bitmap from a vector image file.

export_alembic

Exports Alembic with custom settings.

export_obj

Exports Obj with custom settings.

image_copy_32bit

Copies the internal data of a 32 bit per-channel image to a new one.

import_obj

Imports Obj with custom settings.

import_sketchup

Imports Sketchup File with custom settings.

import_step

Imports STP/STEP with custom settings.

memory_file_bitmap

Writes/Reads a bitmap to/from memory.

memory_file_data

Writes/Reads simple data to/from memory.

texture_paths

Sets and gets global texture paths (Preferences->Files->Paths).

Math

Example

Description

_c4d_geraycollider

Demonstrates ray casting.

_c4d_kdtree

Demonstrates how to use KDTree to find neighboring points in a mesh.

_c4d_matrix

Demonstrates working with matrices.

_c4d_noise

Demonstrates working with noise functions.

_c4d_quaternion

Demonstrates working with quaternions.

_c4d_vector

Demonstrates working with vectors.

_mxutils_random

Demonstrates deterministic random values with mxutils.Random.

Misc

Example

Description

mxutils_checktype

Demonstrates type and iterable validation with mxutils.

mxutils_debugprint

Demonstrates mxutils helpers for diagnosing Cinema 4D scene data.

mxutils_decorators

Demonstrates mxutils helpers for diagnosing Cinema 4D scene data.

mxutils_localimportpath

Demonstrates importing a package relative to a saved Python script.

mxutils_symboltranslationcache

Demonstrates translating Cinema 4D symbols with SymbolTranslationCache.

script_load

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

geometry_cache

Explains the geometry model of the Cinema API in Cinema 4D.

geometry_edges

Demonstrates handling edges in polygon objects at the example of splitting edges.

geometry_extrude

Demonstrates how to modify polygonal geometry at the example of extruding polygons.

geometry_flatten

Demonstrates how to deform points of a point object at the example of ‘flattening’ the selected polygons in a polygon object.

geometry_polygon_object

Explains the user-editable polygon object model of the Cinema API.

geometry_sds_weights

Demonstrates how to read and write data of an SDS weight tag.

geometry_spline_object

Explains the user-editable spline object model of the Cinema API.

geometry_transfer_axis

Demonstrates how to ‘transfer’ the axis of a point object to another object while keeping its vertices in place.

lod

Demonstrates creating and configuring LOD objects.

modeling_command_bridge

Demonstrates how to execute the ‘Bridge’ tool.

modeling_command_current_state

Demonstrates how to execute the ‘Current State to Object’ tool.

modeling_command_edge_smooth

Demonstrates how to execute the ‘Edge Smooth’ tool.

modeling_command_extrude

Demonstrates how to use the SendModelingCommand (SMC) function in general at the example of the ‘Extrude’ tool.

modeling_command_flatten

Demonstrates how to execute the ‘Flatten’ tool.

modeling_command_join

Demonstrates how to execute the ‘Join’ tool.

normal_tag

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.

reduction_create

Creates a new PolygonReduction object.

reduction_edge_level

Reduces the active PolygonObject to the given edge count.

reduction_preprocess

Configures the given PolygonReduction object. Reduces the given PolygonObject to 25%.

reduction_triangle_level

Copyright: MAXON Computer GmbH Author: Yannick Puech

reduction_vertex_level

Reduces the active PolygonObject to the given vertex count.

snap_3d_point

Enables the snap if it’s not already the case. Sets it to 3D Type and also to Point mode.

snap_quantize

Enables the quantize if it’s not already the case. Defines quantize Move and Scale step.

snap_workplane

Retrieves the current workplane position and object. Locks this workplane so it can’t be edited.

uv_command

Calls BodyPaint 3D UV commands.

uv_geometry

Explains how to generate UVW data for polygon objects.

uv_pin_deselect

Removes the polygon point selection to the uv points pinned.

uv_pin_points

Sets the polygon point selection to the uv points pinned.

uv_pin_select

Adds the polygon point selection to the uv points pinned.

uv_seams

Copies the UV seams to the edge polygon selection.

vertex_color_points

Gets and Sets Vertex Colors in Point mode: Changes all black Vertex Colors to red.

vertex_color_polygons

Gets and Sets Vertex Colors in Polygon mode: Changes all vertex colors to red.

volume_boolean_mesh

Converts a Polygon Object to a Volume. Does a boolean operation over two Volume objects. Converts the resulting volume into a Polygon Object.

volume_builder_access

Retrieves a volume object from a volume builder.

volume_builder_add_object

Creates a volume builder and adds a cube object to it. Configures cube’s object settings.

volume_builder_create

Creates a volume builder and inserts it into the active document.

volume_builder_inputs

Iterates over all input of a Volume Builder.

volume_command_sphere

Creates a sphere volume with the corresponding command.

volume_command_spline

Creates a volume from the selected spline object.

volume_curl

Creates a new vector volume object with a curl filter applied from an existing Volume Builder set as vector mode.

volume_export_mesh

Convert a Polygon Object to a Volume and save this volume to a VDB File Save a VDB file.

volume_gradient_sphere

Create a Spherical Volume filled with gradient data.

volume_grid_read

Reads the Float value of the first channel available from a Volume stored in a Volume Builder.

volume_grid_write

Create a volume from scratch and assign values to voxels.

volume_import_vdb

Loads a VDB file to a c4d.VolumeObject.

volume_mesh_conversion

Convert a Polygon Object to a Volume and convert it back to a Polygon Object

volume_mix_meshes

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.

volume_mix_vectors

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.

volume_vdb_import

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.

volume_vector_to_fog

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

graph_descriptions_basics

Demonstrates how graph descriptions create and modify node graphs.

graph_descriptions_commands

Demonstrates graph description commands.

graph_descriptions_queries

Demonstrates graph description queries, including lazy color and vector literals.

graph_descriptions_references

Demonstrates graph description references together with lazy color and URL literals.

nodes_associate_nodes

Demonstrates how to associate nodes in a Maxon API graph with their corresponding Cinema 4D API surrogate elements.

nodes_create_or_get_graphs

Demonstrates creating or getting node graphs in a scene.

nodes_graph_entities

Demonstrates the inner structure of node graphs and how to find entities in them.

nodes_group

Retrieve the selected node material and group the node that are selected.

nodes_info

Retrieve information about the selected port of a selected material.

nodes_material_access

Demonstrates accessing node materials and their graph contents in a scene.

nodes_material_create_redshift

Demonstrates setting up a Redshift node material composed out of multiple nodes.

nodes_material_standard

Demonstrates setting up a Standard renderer node material composed out of multiple nodes.

nodes_modify_port

Create a material for the standard node space and modify the value of the BDSF color port.

nodes_selection

This example shows how to select different elements on a node graph. It creates a node material, select ports, print connections and select wires.

nodes_solo

This example shows how to solo a node. It creates a material and solo’s the end node in this material.

nodes_wire_mute

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.

xpresso_create_connect

Creates a Constants and Results node in the Xpresso Tag of the selected object. Connects both Nodes together.

xpresso_delete

Deletes the first node created from the Xpresso Tag of the selected object.

xpresso_from_tag

Retrieves the Node Master (The BaseList2D object that holds all nodes) from an Xpresso Tag.

xpresso_iterate

Loops through all nodes from the Xpresso Tag of the selected object. Checks if it’s a Constant Node.

xpresso_move

Moves the first node in the Graph View created from the Xpresso Tag of the selected object.

Plugins

Example

Description

unicode_encode_strings

Provides an example for how one could realize a string encoding pipeline for plugin resources.

Rendering

Example

Description

_c4d_renderdata

No short description provided.

batch_render_postprocess

Demonstrates to manipulate the file outputs of a batch render post process once the rendering has finished.

batch_render_preprocess

Demonstrates how to pre-process multiple documents before adding them to the batch renderer for rendering.

ocio

Demonstrates how to read, write, and convert colors in an OpenColorIO (OCIO) color-managed document in Cinema 4D.

render_complex

Demonstrates the details and manual handling of a programmatic rendering process.

render_hardware

Demonstrates how carry out a ‘hardware preview’ rendering, i.e., a rendering of what is shown in the viewport using the hardware renderer.

render_openexr

Configures OpenEXR output render format with SetImageSettingsDictionary() then reads these with GetImageSettingsDictionary().

render_preroll

Demonstrates how to render document from or at a given frame after prerolling it.

render_set_engine

Demonstrates how to manipulate the render settings of a rendering, specifically also the used render engine.

render_simple

Demonstrates a simple way to programmatically render a document to either memory or disk.

render_tiles

Demonstrates how to render a document split into tiles which can be composited back together to a full image.

render_token

Renders a BaseDocument and saves the resulting image using a filename handling tokens.

Scene

Example

Description

_c4d_atom

Demonstrates important functions for the type c4d.C4DAtom.

_c4d_baselist2d

Demonstrates important functions for the type c4d.BaseList2D.

_c4d_gelistnode

Demonstrates important functions for the type c4d.GeListNode.

documents

Demonstrates basic document operations.

layers

Demonstrates how to assign a scene element to a layer.

objects

Demonstrates basic operations on objects.

parameters

Demonstrates different ways to access and modify parameters of Cinema 4D scene elements.

takes

Demonstrates the fundamental operations of the Take System.

traversal

Demonstrates scene traversal.

undos

Demonstrates adding undo steps for document modifications.

userdata

Demonstrates how to work with user data parameters.