<?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[Python Effectors]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<p dir="auto">I've made a simply python effector that allows me to manipulate the color of a effected cloner. That works fine but when I creat an instance of that object and start moving it in 3D space, I get a ton of these errors:</p>
<p dir="auto">Traceback (most recent call last):<br />
File "'&lt;Python&gt;'", line 18, in main<br />
TypeError: object of type 'NoneType' has no len()</p>
<p dir="auto"><a href="https://www.dropbox.com/s/4cui1f7t8a1l0n9/PyEffectorTest_v1.c4d?dl=0" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.dropbox.com/s/4cui1f7t8a1l0n9/PyEffectorTest_v1.c4d?dl=0</a></p>
<pre><code class="language-python">import c4d
from c4d.modules import mograph as mo
#Welcome to the world of Python

def main():
    linked = op[c4d.ID_USERDATA,1]
    md = mo.GeGetMoData(op)
    md2 = mo.GeGetMoData(linked)
    EB = op[c4d.ID_USERDATA,2]

    if md is None: return False
    
    cnt = md.GetCount()
    clr = md.GetArray(c4d.MODATA_COLOR)
    clr2 = md2.GetArray(c4d.MODATA_COLOR)    

    if cnt &gt; 0: 
        print cnt
    
    #for i in xrange(0,cnt):
        #clr[i] = clr2[i] + (clr2[i] * c4d.Vector(EB))
    
    md.SetArray(c4d.MODATA_COLOR, clr, True)
    return True


    c4d.EventAdd()
    
    

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">Does anyone have an idea how to get around this?</p>
]]></description><link>http://developers.maxon.net/forum/topic/10968/python-effectors</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 02:12:17 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10968.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Sep 2018 22:11:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Python Effectors on Thu, 13 Sep 2018 23:46:06 GMT]]></title><description><![CDATA[<p dir="auto">Thanks dskeith, that code worked perfectly. Thanks for that!</p>
]]></description><link>http://developers.maxon.net/forum/post/55688</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55688</guid><dc:creator><![CDATA[bencaires]]></dc:creator><pubDate>Thu, 13 Sep 2018 23:46:06 GMT</pubDate></item><item><title><![CDATA[Reply to Python Effectors on Thu, 06 Sep 2018 13:34:36 GMT]]></title><description><![CDATA[<p dir="auto">I have moved this thread to "Cinema 4D Development" category.</p>
]]></description><link>http://developers.maxon.net/forum/post/55599</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55599</guid><dc:creator><![CDATA[a_block]]></dc:creator><pubDate>Thu, 06 Sep 2018 13:34:36 GMT</pubDate></item><item><title><![CDATA[Reply to Python Effectors on Thu, 06 Sep 2018 08:15:59 GMT]]></title><description><![CDATA[<p dir="auto">Took a second look. It seems that you're trying to iterate on a list that doesn't exist. <code>xrange(0,0)</code> returns <code>None</code> not <code>[]</code>. This likely happens because the instanced effector can't access the MoData of the other cloner that's been instanced (or something like that). I've taken the liberty of reworking your code to be a bit more error-tolerant:</p>
<pre><code>import c4d
from c4d.modules import mograph as mo

def main():
    # Retrieve User Inputs
    EB = op[c4d.ID_USERDATA,2]
    linked = op[c4d.ID_USERDATA,1]
    if linked is None:
        return True
    
    md = mo.GeGetMoData(op)
    if md is None:
        return True
    
    linked_md = mo.GeGetMoData(linked)
    if linked_md is None:
        return True
    
    md_count = md.GetCount()
    if not md_count:
        return True
    
    linked_md_count = linked_md.GetCount()
    if not linked_md_count:
        return True
    
    # If counts don't match between cloners, use the smaller number.
    clone_count = min([md_count, linked_md_count])
    
    colors = md.GetArray(c4d.MODATA_COLOR)
    if colors is None:
        return
    
    linked_colors = linked_md.GetArray(c4d.MODATA_COLOR)
    if linked_colors is None:
        return

    for i in xrange(clone_count):
        colors[i] = linked_colors[i] + (linked_colors[i] * c4d.Vector(EB))
    
    md.SetArray(c4d.MODATA_COLOR, colors, True)
    return True
    

if __name__=='__main__':
    main()
</code></pre>
<p dir="auto">But looking at your scene I'm not sure you'll get the result you want trying to colorize one cloner with a cloner object it's cloning.</p>
]]></description><link>http://developers.maxon.net/forum/post/55584</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55584</guid><dc:creator><![CDATA[dskeith]]></dc:creator><pubDate>Thu, 06 Sep 2018 08:15:59 GMT</pubDate></item></channel></rss>