<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[My goal is to Export all the Child objects in a Cloner as individual STL files.]]></title><description><![CDATA[<p dir="auto">My goal is to Export all the Child objects (or the top group) in a Cloner as individual STL files.</p>
<p dir="auto">Here is my initial code to simply list the Child items.<br />
But I get syntax errors for lines 32, 29 and 4 even at this early stage <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":-(" alt="😞" /></p>
<pre><code>import c4d

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

    children = obj.GetChildren()
    if not children:
        print("The selected Cloner has no children.")
    else:
        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:
        return

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

    selected_obj = selection[0]

    # List the children of the selected object
    list_cloner_children(selected_obj)

if __name__ == '__main__':
    main()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/14912/my-goal-is-to-export-all-the-child-objects-in-a-cloner-as-individual-stl-files</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 10:41:02 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/14912.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Jul 2023 19:22:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to My goal is to Export all the Child objects in a Cloner as individual STL files. on Wed, 02 Aug 2023 17:57:33 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Ilia,<br />
Let me digest your extremely kind advice and example, learn from it, and come back tom you.<br />
Kind regards,<br />
James.</p>
]]></description><link>http://developers.maxon.net/forum/post/72157</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72157</guid><dc:creator><![CDATA[jrpmedia]]></dc:creator><pubDate>Wed, 02 Aug 2023 17:57:33 GMT</pubDate></item><item><title><![CDATA[Reply to My goal is to Export all the Child objects in a Cloner as individual STL files. on Wed, 02 Aug 2023 16:33:52 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jrpmedia">@<bdi>jrpmedia</bdi></a>,</p>
<p dir="auto">Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us!</p>
<h4>Getting Started</h4>
<p dir="auto">Before creating your next postings, we would recommend making yourself accustomed with our <a href="https://plugincafe.maxon.net/guidlines_cp" target="_blank" rel="noopener noreferrer nofollow ugc">Forum and Support Guidelines</a>, as they line out details about the Maxon SDK Group support procedures. Of special importance are:</p>
<ul>
<li><a href="https://plugincafe.maxon.net/guidlines_cp#support-scope" target="_blank" rel="noopener noreferrer nofollow ugc">Support Procedures: Scope of Support</a>: Lines out the things we will do and what we will not do.</li>
<li><a href="https://plugincafe.maxon.net/guidlines_cp#support-data" target="_blank" rel="noopener noreferrer nofollow ugc">Support Procedures: Confidential Data</a>: Most questions should be accompanied by code but code cannot always be shared publicly. This section explains how to share code confidentially with Maxon.</li>
<li><a href="https://plugincafe.maxon.net/guidlines_cp#forum" target="_blank" rel="noopener noreferrer nofollow ugc">Forum Structure and Features</a>: Lines out how the forum works.</li>
<li><a href="https://plugincafe.maxon.net/guidlines_cp#question" target="_blank" rel="noopener noreferrer nofollow ugc">Structure of a Question</a>: Lines out how to ask a good technical question. It is not mandatory to follow this exactly, but you should follow the idea of keeping things short and mentioning your primary question in a clear manner.</li>
</ul>
<h4>About your First Question</h4>
<p dir="auto">Please excuse delayed answer.</p>
<p dir="auto">The reason for the syntax errors is in using nonexistent type constant, it should be <a href="https://developers.maxon.net/docs/cpp/2023_2/group___object_types.html#ga0256b7a5977d82c4d5489f9e5b6ebd28" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.Omgcloner</a>.</p>
<p dir="auto">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.</p>
<p dir="auto">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 <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html" target="_blank" rel="noopener noreferrer nofollow ugc">BaseDocument</a>, copy your child over to there using <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/index.html?highlight=getclone#C4DAtom.GetClone" target="_blank" rel="noopener noreferrer nofollow ugc">GetClone()</a> and then export this document using <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/index.html?highlight=savedocument#c4d.documents.SaveDocument" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.documents.SaveDocument()</a>. You should, however, be careful with such approach as cloning objects can have side effects due to dependencies they have, <a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/AliasTrans/index.html?highlight=aliastrans#c4d.AliasTrans" target="_blank" rel="noopener noreferrer nofollow ugc">AliasTrans</a> might be something of interest for you in this scenario.</p>
<p dir="auto">If you on the other hand, want to export actual objects generated by cloner, then you can try making use of <a href="https://developers.maxon.net/docs/py/2023_2/consts/MCOMMAND.html?highlight=mcommand_makeeditable" target="_blank" rel="noopener noreferrer nofollow ugc">MCOMMAND_MAKEEDITABLE</a> command. Please find the snippet showing this approach below. You can also find check there the usage of the aforementioned functions.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
<p dir="auto"><img src="https://developers.maxon.net/forum/assets/uploads/files/1690993902974-cinema_4d_jacvfznl81.gif" alt="Cinema_4D_jacvfZnL81.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto">Code:</p>
<pre><code>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()
		docTemp.InsertObject(obj.GetClone(c4d.COPYFLAGS_NONE))
		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__':
	main(r'D:\\temp\\')
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/72156</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/72156</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Wed, 02 Aug 2023 16:33:52 GMT</pubDate></item></channel></rss>