Unsolved My goal is to Export all the Child objects in a Cloner as individual STL files.

My goal is to Export all the Child objects (or the top group) in a Cloner as individual STL files.

Here is my initial code to simply list the Child items.
But I get syntax errors for lines 32, 29 and 4 even at this early stage :-(

import c4d

def list_cloner_children(obj):
    if obj is None or obj.GetType() != c4d.Ocloner:
        print("Please select a Cloner object.")

    children = obj.GetChildren()
    if not children:
        print("The selected Cloner has no children.")
        print("Children of selected Cloner:")
        for child in children:
            print("  ", child.GetName())

def main():
    # Get the active document
    doc = c4d.documents.GetActiveDocument()
    if doc is None:

    # Get the first selected object
    selection = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
    if not selection:
        print("No objects selected.")

    selected_obj = selection[0]

    # List the children of the selected object

if __name__ == '__main__':

Always ...

Hello @jrpmedia,

Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us!

Getting Started

Before creating your next postings, we would recommend making yourself accustomed with our Forum and Support Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are:

About your First Question

Please excuse delayed answer.

The reason for the syntax errors is in using nonexistent type constant, it should be c4d.Omgcloner.

The way you described your goal can be interpreted in different ways resulting in different approaches. Please try to give more details to decrease the amount of ambiguity in your next postings. We've also reformatted your posting, please try using formatting "code" block for when pasting code snippets.

If you like to export the child reference objects from your cloner, then your code snippet would work just fine. The last missing piece there would be exporting children individually. For that I can recommend an approach to create a new BaseDocument, copy your child over to there using GetClone() and then export this document using c4d.documents.SaveDocument(). You should, however, be careful with such approach as cloning objects can have side effects due to dependencies they have, AliasTrans might be something of interest for you in this scenario.

If you on the other hand, want to export actual objects generated by cloner, then you can try making use of MCOMMAND_MAKEEDITABLE command. Please find the snippet showing this approach below. You can also find check there the usage of the aforementioned functions.




import c4d, typing, os

def main(outputDirectory: str):
	doc: c4d.documents.BaseDocument = c4d.documents.GetActiveDocument()

	# Get the first selected object
	currentSelectedObjs: list[c4d.BaseList2D] = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
	if not currentSelectedObjs:
		return print("No objects selected.")
	# Check if active object is cloner
	if currentSelectedObjs[0] is None or currentSelectedObjs[0].GetType() != c4d.Omgcloner:
		return print("Please select a Cloner object.")
	# Clone document to avoid corrupting original data
	docClone: c4d.documents.BaseDocument = doc.GetClone(c4d.COPYFLAGS_NONE)
	selectedObjs: list[c4d.BaseList2D] = docClone.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
	if not selectedObjs or selectedObjs[0] is None or selectedObjs[0].GetType() != c4d.Omgcloner:
		return print("Something went wrong")
	# Bake cloner objects
	selectedObj: c4d.BaseList2D = selectedObjs[0]
	res: list[c4d.BaseList2D] | bool = c4d.utils.SendModelingCommand(c4d.MCOMMAND_MAKEEDITABLE, [selectedObj])
	if not isinstance(res, list) or not res:
		return print("Couldn't execute Make Editable command")
	# Iterate over baked cloner children
	for obj in res[0].GetChildren():
		docTemp: c4d.documents.BaseDocument = c4d.documents.BaseDocument()
		filePath: str = os.path.join(outputDirectory, obj.GetName() + '.stl')
		print(f'Saving object {obj.GetName()} to {filePath}')
		c4d.documents.SaveDocument(docTemp, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_STL_EXPORT)

if __name__ == '__main__':

MAXON SDK Specialist

Thank you Ilia,
Let me digest your extremely kind advice and example, learn from it, and come back tom you.
Kind regards,

Always ...