<?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[GetChildren into an InExcludeData]]></title><description><![CDATA[<p dir="auto">Hi there!</p>
<p dir="auto">I'm trying to add all the children (no grandchildren) underneath an object to an InExcludeData on the parent.</p>
<p dir="auto">This s what I could come up with but it doesn't seem to work for some reason that I can't figure out.</p>
<pre><code>import c4d

def main():
    obj = op.GetObject()
    print (obj)
    children = obj.GetChildren()
    print (children)
    
    GroupList = c4d.InExcludeData()
    GroupList.InsertObject(children, 1)
    obj[c4d.ID_USERDATA,1] = GroupList
    c4d.EventAdd()
</code></pre>
<p dir="auto">This is the error I'm getting.</p>
<pre><code>Traceback (most recent call last):
  File "Python", line 10, in main
TypeError: argument 1 must be c4d.BaseList2D, not list
</code></pre>
<p dir="auto"><a href="/forum/assets/uploads/files/1722314421922-test_add_heiarchy.c4d">TEST_ADD_HEIARCHY.c4d</a><br />
Any idea how to fix that ?</p>
]]></description><link>http://developers.maxon.net/forum/topic/15622/getchildren-into-an-inexcludedata</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 17:42:25 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/15622.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Jul 2024 04:40:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetChildren into an InExcludeData on Fri, 16 Aug 2024 13:32:22 GMT]]></title><description><![CDATA[<p dir="auto">Thank you so much <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/i_mazlov">@<bdi>i_mazlov</bdi></a> . I'm still new to this and your reply is extremely helpful. Thanks again!<br />
Apologies for the double post. I wanted to completely remove the old post since I kinda spammed too many replies on it while I was figuring out what was wrong.<br />
Appreciate the help. Have a good day!</p>
]]></description><link>http://developers.maxon.net/forum/post/74785</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/74785</guid><dc:creator><![CDATA[hoffwerr]]></dc:creator><pubDate>Fri, 16 Aug 2024 13:32:22 GMT</pubDate></item><item><title><![CDATA[Reply to GetChildren into an InExcludeData on Thu, 01 Aug 2024 15:35:05 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/hoffwerr">@<bdi>hoffwerr</bdi></a>,</p>
<p dir="auto">First of all, please make sure you actually visited our <a href="https://developers.maxon.net/forum/topic/15244/support-procedures" target="_blank" rel="noopener noreferrer nofollow ugc">Support Procedures</a> page.</p>
<p dir="auto">Your issue here is a very basic python type mismatch. I know that dealing with some 3rd party APIs and leaky documentation can be frustrating and at some point even obvious things can be perceived as impossible, but</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">Regarding your question. The issue here is that you're trying to insert the list of objects <code>list[c4d.BaseObject]</code> using function <a href="https://developers.maxon.net/docs/py/2024_5_0/modules/c4d/CustomDataType/InExcludeData/index.html?highlight=insertobject#InExcludeData.InsertObject" target="_blank" rel="noopener noreferrer nofollow ugc">InsertObject()</a> that only expects a single object. You need to iterate your list of objects, e.g. using for loop:</p>
<pre><code class="language-python">for child in children:
    GroupList.InsertObject(child, 1)
</code></pre>
<p dir="auto">A couple more things about your code.</p>
<ol>
<li>Calling <a href="https://developers.maxon.net/docs/py/2024_5_0/modules/c4d/index.html?highlight=eventadd#c4d.EventAdd" target="_blank" rel="noopener noreferrer nofollow ugc">c4d.EventAdd()</a> is useless from within the Python tag, as mentioned in the documentation, it does nothing in this case</li>
<li>Populating your InExcludeList every time the python tag is executed is not ideal (it's slow!). Hence, you'd need some smarter way to distinguish when you need to repopulate the list and when it is not necessary. There's at least one thread about it, where Maxime mentioned this issue: <a href="https://developers.maxon.net/forum/topic/13328/execute-python-tag-only-when-hierarchy-changes" target="_blank" rel="noopener noreferrer nofollow ugc">Execute python tag only when hierarchy changes</a>. Please check the code snippet below that implements a <strong>very draft</strong> way of doing so, simply by comparing the number of children. Ideally, you need to keep track of the entire children list and do actual comparison there, but this can be redundant depending on your goals.</li>
</ol>
<p dir="auto">There's one another thing. Please do not give up old threads and start new ones instead, this only makes more clutter on the forum and doesn't help with processing your questions. Hence I've resurrected <a href="https://developers.maxon.net/forum/topic/15608/xpresso-pyhton-convert-link-list-hierarchy-node-to-in-exclusion" target="_blank" rel="noopener noreferrer nofollow ugc">your previous thread</a>. For your future threads please consolidate your consequent answers in a single posting and do not duplicate threads.</p>
<p dir="auto">Cheers,<br />
Ilia</p>
<p dir="auto">Python tag script (to be inserted on a Group effector):</p>
<pre><code class="language-python">import c4d

doc: c4d.documents.BaseDocument  # The document containing this field object.
op: c4d.BaseTag # The Python tag containing this code.

childrenCount: int = 0  # keep number of children globally between main() calls

def main() -&gt; None:
    global childrenCount
    obj: c4d.BaseObject = op.GetObject()

    children: list[c4d.BaseObject] = obj.GetChildren()
    if childrenCount == len(children):  # early exit if number of children hasn't changed
        return

    childrenCount = len(children)
    print('Updating InExclude list')

    inexcl = c4d.InExcludeData()
    for child in children:  # Process children one-by-one
        inexcl.InsertObject(child, 1)

    obj[c4d.MGGROUPEFFECTOR_EFFECTORLIST] = inexcl
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/74676</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/74676</guid><dc:creator><![CDATA[i_mazlov]]></dc:creator><pubDate>Thu, 01 Aug 2024 15:35:05 GMT</pubDate></item></channel></rss>