<?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[logic problem to obtain the entire hierarchy of the object]]></title><description><![CDATA[<p dir="auto"><a href="https://developers.maxon.net/forum/topic/13045/alternative-way-to-iterate-list-other-than-getnext/3" target="_blank" rel="noopener noreferrer nofollow ugc">https://developers.maxon.net/forum/topic/13045/alternative-way-to-iterate-list-other-than-getnext/3</a><br />
In my search for a solution, I came across this post that works well and returns a list of all child objects in order. However, is there a way to save lists within other lists containing all the objects so I can keep track of the hierarchy?</p>
<p dir="auto">maybe in this structure:<br />
<img src="/forum/assets/uploads/files/1718143808307-a7f37e63-91f4-4a3f-ac41-dbd03b8ec298-image.png" alt="a7f37e63-91f4-4a3f-ac41-dbd03b8ec298-image.png" class=" img-fluid img-markdown" /></p>
<pre><code>         hierarchy = [obj1,  
         obj2[obj2.5, [obj2.75],
         obj3[obj4, [obj5&rsqb;&rsqb;
</code></pre>
]]></description><link>http://developers.maxon.net/forum/topic/15566/logic-problem-to-obtain-the-entire-hierarchy-of-the-object</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Jul 2026 03:19:09 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15566.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 11 Jun 2024 22:23:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to logic problem to obtain the entire hierarchy of the object on Thu, 13 Jun 2024 08:25:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/pyxelrigger">@<bdi>pyxelrigger</bdi></a> ,</p>
<p dir="auto">Unfortunately your question is out of the <a href="https://developers.maxon.net/forum/topic/15244/support-procedures/3" target="_blank" rel="noopener noreferrer nofollow ugc">scope of support</a> on this forum, namely:</p>
<blockquote>
<p dir="auto">We cannot provide support on learning C++, Python, or one of their popular third-party libraries.</p>
</blockquote>
<p dir="auto">With that's said, I'm kind of missing the main idea behind your question, in other words what are you trying to achieve?</p>
<p dir="auto">Is it just another (e.g. simply more convenient) data structure for the hierarchy? If so, then you're free to create whatever data structure fits your need the best. For example, check a very fast draft code snippet below.</p>
<p dir="auto">Is it that you want to track changes of the hierarchy? If so, then you might need to come up with some more complex setup, e.g. involving using the <a href="https://developers.maxon.net/docs/py/2024_4_0a/consts/MSG_CORE_EVMSG.html?highlight=evmsg_change#c4d.EVMSG_CHANGE" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.EVMSG_CHANGE</a> message. Please, refer to a great Ferdinand's answer here: <a href="https://developers.maxon.net/forum/topic/14747/best-way-to-detect-an-object-has-been-deleted/4" target="_blank" rel="noopener noreferrer nofollow ugc">Best way to detect an object has been deleted?</a></p>
<p dir="auto">Please also consider visiting our <a href="https://developers.maxon.net/forum/topic/15244/support-procedures/4" target="_blank" rel="noopener noreferrer nofollow ugc">How to ask Questions</a> section of the support procedures for your future postings.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
<p dir="auto">A super draft example of nested lists hierarchy representation:</p>
<pre><code class="language-python">import c4d
 
doc: c4d.documents.BaseDocument
 
class HierarchyObject:
    def __init__(self, op):
        self.op = op
        self.children = []
 
        child = self.op.GetDown() if op else doc.GetFirstObject()  # recursion entry point
        while child:
            self.addChild(HierarchyObject(child))  # recursion
            child = child.GetNext()
   
    def addChild(self, child):
        self.children.append(child)
   
    def toString(self, indentation: int = 0):
        indentStr: str = '\t' * indentation
        name: str = self.op.GetName() if self.op else '___root___'
        s: str = f'{indentStr}&lt;{name}'
        if self.children:
            s += ':'
            for child in self.children:
                s += f'\n{child.toString(indentation + 1)}'
            s += f'\n{indentStr}'
        s += '&gt;'
        return s
 
    def __str__(self):
        return self.toString()
 
 
if __name__=='__main__':
    root: HierarchyObject = HierarchyObject(None)    
    print(root)
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/74467</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/74467</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Thu, 13 Jun 2024 08:25:21 GMT</pubDate></item></channel></rss>