This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.symbols – the symbols module

To use this module we recommend the following code of line:

from c4d import symbols as sy
#the module can be called by using the reference <sy>

In CINEMA 4D you can change or read the values of objects, tags, nodes via an ID. For instance the radius or the count of segments of a sphere.

../../_images/attr.png

The easiest way to set/get values of an object:

#read value at item position 1110
attr = sphere[1110]

#set '12.3' as value
sphere[1110] = 12.3

You can just pass a simple int so you can set or get a value of the object. This works fine but its hard to see for what this value is for.

Each object, tag, node,... in CINEMA 4D has its own public header file which is located in a res folder. Also objects which are shipped with CINEMA 4D have these header files, where all attributes are noted down, which you can see in the Attribute-Manager. Here is the content of the Sphere header file:

../../_images/headerfile.png

On startup of CINEMA 4D, Py4D catches all these entries and adds them to this module. Also the Header files of external plugins will be parsed and can be used. Just remember that such a constant is just available in the CINEMA 4D version where the corresponding plugin is installed:

from c4d import symbols as sy

#read value at item position 1110/PRIM_SPHERE_RAD
radius = sphere[sy.PRIM_SPHERE_RAD]

#set '12.3' as value
sphere[sy.PRIM_SPHERE_RAD] = 12.3

The next time you open the script, you will immediatley see for what this constant is for and it’s much easier to avoid wrong IDs. There is just the question of how you get these constants’ names. Well the first way is to locate the corresponding Header file and look for the attribute which you want to get or set. At first you create an instance of the object in your document and drag it to the output field of the console.

../../_images/object_drag.png

Select the object so it appears in the Attribute-Manager. Just drag the attribute to the same region of the console. The name of this attribute will be written to the input field of the console at the bottom. That’s it!

../../_images/attr_drag.png

Note

In the console, the symbols module is imported with from c4d.symbols import * on default, so you have full access in the console without any namespace handler. If you import this module how we recommend it on the top of this page (from c4d import symbols as sy) you can access the constant by adding sy like sy.YOUR_CONSTANT.

See also

Object ID’s types:
How you create an object.

This Page