<?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[File import and doc merge -&gt; InsertAfter or c4d.PREF_INTERFACE_I_BOTTOM]]></title><description><![CDATA[<p dir="auto">Dear Team,<br />
I am trying to import files and place them in the object tree in the right order,</p>
<p dir="auto">i tried to set the preferences with <code>c4d.PREF_INTERFACE_I_BOTTOM</code> before import but it did not change my order.</p>
<pre><code>        interface_preferences = c4d.GetWorldContainer()
        previous_insert_at = interface_preferences.GetInt32(c4d.PREF_INTERFACE_INSERTAT)
        interface_preferences.SetInt32(c4d.PREF_INTERFACE_INSERTAT, c4d.PREF_INTERFACE_I_BOTTOM, )
</code></pre>
<p dir="auto">Is there a convenient way or do i need to move the "node" manually to the bottom on each import ...<br />
or more universal for me is there a way to sort root nodes in the Object manager tree ? (only found an old coffee thread ... )<br />
thanks in advance ...<br />
mogh</p>
]]></description><link>http://developers.maxon.net/forum/topic/16443/file-import-and-doc-merge-insertafter-or-c4d.pref_interface_i_bottom</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 08:59:12 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/16443.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Sep 2026 09:53:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to File import and doc merge -&gt; InsertAfter or c4d.PREF_INTERFACE_I_BOTTOM on Wed, 16 Sep 2026 10:01:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ferdinand">@<bdi>ferdinand</bdi></a> Thanks for pointing that out. Indeed,  <code>matrix = obj.GetMg()</code>  and  <code>obj.SetMg(matrix)</code>  are not necessary; this is leftover code from when it was previously used to insert into the child or sibling level of the selected object.</p>
<p dir="auto">Cheers,<br />
Anlv</p>
]]></description><link>http://developers.maxon.net/forum/post/77351</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/77351</guid><dc:creator><![CDATA[Anlv]]></dc:creator><pubDate>Wed, 16 Sep 2026 10:01:40 GMT</pubDate></item><item><title><![CDATA[Reply to File import and doc merge -&gt; InsertAfter or c4d.PREF_INTERFACE_I_BOTTOM on Wed, 16 Sep 2026 09:53:12 GMT]]></title><description><![CDATA[<p dir="auto">Hey <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/mogh">@<bdi>mogh</bdi></a>,</p>
<p dir="auto">let me clarify things first a bit.</p>
<p dir="auto">Reproduce:</p>
<ol>
<li>You have a scene A in an alien scene format such as FBX or OBJ.</li>
<li>You have an existing native Cinema 4D scene B.</li>
<li>You are trying to merge A into B.</li>
</ol>
<p dir="auto">Result:<br />
The objects of A appear before the objects of B in the scene hierarchy of the merged scene. Even when you change the insertion order in Preferences &gt; Interface.</p>
<p dir="auto">First of all, it is not very surprising that "insert at" does not work (and "paste at" does neither), because these are for individual objects within a scene, not for merging entire scenes. What you are effectively missing is a scene merge order option and this does not really have something to do with importers. This would be addressed best by a feature request in our <a href="https://help.maxon.net/" target="_blank" rel="noopener noreferrer nofollow ugc">Support Center</a>.</p>
<p dir="auto">With a pinch of Python, you can solve this yourself as demonstrated by <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/anlv">@<bdi>Anlv</bdi></a> (thanks!). Using <code>BaseList2D.GetGUID</code> as <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/anlv">@<bdi>Anlv</bdi></a> did is okay, but the more native solution would be <code>hash(obj)</code>, i.e., <code>C4DAtom.__hash__</code>. Scene elements are for quite a while now natively hashable, so you can for example do this:</p>
<pre><code class="language-python">roots: set[int] = { hash(obj) for obj in doc.GetObjects() }
new_roots: set[int] = roots.intersection({ hash(obj) for obj in new_doc.GetObjects() })
</code></pre>
<p dir="auto">And it will give you the set of all root level hashes (GeMarker IDs). I think also the transform copying <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/anlv">@<bdi>Anlv</bdi></a> does at the end of the script should not be necessary, because these are root level objects, and therefore removing and re-adding them will not affect their transforms (as they have no parents to which their transform would be relative to). But I have not run <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/anlv">@<bdi>Anlv</bdi></a>'s full script myself, so it could be that I am overlooking something.</p>
<p dir="auto">Cheers,<br />
Ferdinand</p>
]]></description><link>http://developers.maxon.net/forum/post/77350</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/77350</guid><dc:creator><![CDATA[ferdinand]]></dc:creator><pubDate>Wed, 16 Sep 2026 09:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to File import and doc merge -&gt; InsertAfter or c4d.PREF_INTERFACE_I_BOTTOM on Wed, 16 Sep 2026 08:59:35 GMT]]></title><description><![CDATA[<pre><code>import c4d

doc: c4d.documents.BaseDocument  # The currently active document.
op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.

def main() -&gt; None:

    obj = c4d.BaseObject(c4d.Ocube)

    # Insert after the last root object.
    roots = doc.GetObjects()
    doc.InsertObject(obj, pred=roots[-1] if roots else None)

    c4d.EventAdd()
    
if __name__ == '__main__':
    main()
</code></pre>
<p dir="auto">Hope this helps.<br />
Here is another example that can directly execute the import</p>
<pre><code>import c4d

def main():
    doc = c4d.documents.GetActiveDocument()
    path = c4d.storage.LoadDialog(
        c4d.FILESELECTTYPE_SCENES,
        "Import Scene"
    )
    if not path:
        return

    roots = doc.GetObjects()
    anchor = roots[-1] if roots else None
    old_guids = {obj.GetGUID() for obj in roots}

    flags = (
        c4d.SCENEFILTER_OBJECTS |
        c4d.SCENEFILTER_MATERIALS |
        c4d.SCENEFILTER_MERGESCENE |
        c4d.SCENEFILTER_DIALOGSALLOWED
    )

    c4d.StopAllThreads()
    doc.StartUndo()

    try:
        doc.AddUndo(c4d.UNDOTYPE_CHANGE, doc)

        if not c4d.documents.MergeDocument(doc, path, flags, None):
            c4d.gui.MessageDialog("Import failed.")
            return

        # Find the newly imported root objects.
        imported = [
            obj for obj in doc.GetObjects()
            if obj.GetGUID() not in old_guids
        ]

        # Move them below the previous last root object.
        if anchor:
            for obj in imported:
                matrix = obj.GetMg()
                doc.AddUndo(c4d.UNDOTYPE_CHANGE, obj)
                obj.Remove()
                obj.InsertAfter(anchor)
                obj.SetMg(matrix)
                anchor = obj
    finally:
        doc.EndUndo()
        c4d.EventAdd()

if __name__ == "__main__":
    main()
</code></pre>
<p dir="auto">Cheers,<br />
Anlv</p>
]]></description><link>http://developers.maxon.net/forum/post/77349</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/77349</guid><dc:creator><![CDATA[Anlv]]></dc:creator><pubDate>Wed, 16 Sep 2026 08:59:35 GMT</pubDate></item></channel></rss>