Cinema4D Scripting

Python

Every instance of c4d.BaseList2D owns a reference to an object of the c4d.BaseContainer class. It is basically is an associative array containg all the values of the parameters an object has in the Attribute-Manager.

import c4d

bc = op.GetDataInstance()
bc.SetVector(c4d.PRIM_CUBE_LEN, c4d.Vector(500,100,20))

Note, c4d.BaseContainer.GetDataInstance() returns the original container, NOT A COPY. Modifieng this container will directly modify the object’s parameters. If you want to get a copy, use c4d.BaseObject.GetData()

Accessing the BaseContainer and using subscripting

There is a more convenient way, an alternative of using methods like SetVector, SetReal, etc. The trick is called subscripting using the bracket [] syntax.

import c4d
op[c4d.PRIM_CUBE_LEN] = c4d.Vector( 500, 100, 20)

import c4d

bc = op.GetDataInstance()

bc[c4d.PRIM_CUBE_LEN] = c4d.Vector( 500 , 100 , 20)

import c4d

op[c4d.PRIM_CUBE_LEN] = c4d.Vector( 500, 100, 20 )

Usually Cinema4D store settings for nodes and tools in a BaseContainer.
BaseContainer is very useful class that allow you to store different data type in easy way.
But you will notice there are some cases where Cinema don’t store parameter in BaseContainer, for example some of light and camera parameters are not reachable by Get/Set BaseContainer Methods.

To do

C++ Stuff

General

Why, because I need them, I didn’t say I’m using OpenGL. Besides, the matrix would still not be usable in OpenGL because c4d uses left-handed coordinate system and OpenGL uses right handed-one.

I figured it out in the meantime, so in case anybody ever needs something similar, it’s like this: C4d uses left-handed system. HPB rotation translates to rotation about axes in this way: H is rotation around (0,-1,0) axis (y-axis, the angle is negated), P around (-1,0,0) and B around (0,0-1). Accounting for OpenGL’s right-handed system, the rotations will become rx = p ry = h rz = -b When applying the rotation, the order is rotY(ry)*rotX(rx)*rotZ(rz)

def _GlobalToLocal(self, obj, global_pos) : #""" Returns a point in global coordinate in local space. """
obj_mg = obj.GetMg()
return ~obj_mg * global_pos 

UUID Pointers

General Commands

import c4d  
data = c4d.gui.FontDialog()  
  
for k, v in data:  
  print k, v  
  
font = c4d.FontData()  
font.SetFont(font)

Pipeline

Environment Variables include: C4D_BROWSERLIBS (lib4D presets) C4D_PLUGINS_DIR (plugins) C4D_SCRIPTS_DIR (scripts - R19+)