Hello @coreartz and @wadams,
welcome to the forum and the Cinema 4D coding community. Thank you for reaching out to us @coreartz and thank you @wadams for providing an answer. We have not much to add here, @wadams gave you almost all of the relevant information.
It is noteworthy that Cinema does work very differently than Blender when it comes to its Python interfaces, where Blender takes a more procedural/factory-oriented approach, Cinema 4D is strictly object oriented due to its cache building scene logic. To implement a polygonal generator object, one has to implement a ObjectData
plugin and there overwrite the GetVirtualsObjects
method to build the cache for that object type.
One can also get its feet wet with the Python generator object in Cinema when one wants to implement a simple generator object returning polygonal data, i.e., the equivalent of what is done with ObjectData.GetVirtualObjects()
. See attached example at the end for details. There are no examples in the Python (or C++) SDK for implementing something that wraps around a cloner object. The ObjectData
generator example in the Python SDK is the double circle example, but it deals with spline generators and not with polygonal generators.
Cheers,
Ferdinand
The scene file: example_python_generator.c4d
The result of the Python Generator object with some user data input:

The code:
"""Simple example for a Python Generator object.
Creates a cloner and a cube object and clones the cube with the cloner. The
script expects an user data value with the id 1 one to be present on the
Python Generator object. For simplicity please use the scene file provided.
A Python Generator object can be viewed as entry point into writing an
ObjectData plugin implementing GetVirtualObjects(), since its main() function
is very similar to what one has to do in GetVirtualObjects().
Reference:
[1] Python SDK: Types and Symbols List. url:
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/types/index.html
As discussed in:
https://plugincafe.maxon.net/topic/13470/
"""
import c4d
def main():
"""
"""
# Create a cloner object, as pointed out by wadams, there is unfortunately
# no type symbol for the cloner object, i.e., there is no MGOCLONER
# symbol.
cloner = c4d.BaseObject(1018544)
# Create a cube object as an object for the Mograph cloner to clone.
cube = c4d.BaseObject(c4d.Ocube)
# Return a null object if the allocation of either the cloner or cube
# failed.
if None in (cloner, cube):
return c4d.BaseObject(c4d.Onull)
# Get the user data parameter defining the offset. The attribute op is
# predefined in most scripting object environments in Cinema 4D. In case
# of the Python Generator object it does point to the Python Generator
# object itself.
offset = op[c4d.ID_USERDATA, 1]
# Set the cloner to linear mode and 10 clones with an offset defined by
# the user data. Apart form the console approach described by wadams,
# there is also the symbols description [1] in the Python docs to identify
# required symbols when writing code.
cloner[c4d.ID_MG_MOTIONGENERATOR_MODE] = c4d.ID_MG_MOTIONGENERATOR_MODE_LINEAR
cloner[c4d.MG_LINEAR_COUNT] = 10
cloner[c4d.MG_LINEAR_OBJECT_POSITION] = offset
# Enable the fillet option for the cube object and set the fillet radius
# to 10.0 units.
cube[c4d.PRIM_CUBE_DOFILLET] = True
cube[c4d.PRIM_CUBE_FRAD] = 10.
# Add a phong tag to the cube, so that these filleted corners will be
# shaded nicely.
cube.MakeTag(c4d.Tphong)
# Make the cube object a child of the cloner.
cube.InsertUnder(cloner)
# return the cloner as the cache we did build.
return cloner