<?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[Sampling the falloff of a mograph effector? (python&#x2F;R19)]]></title><description><![CDATA[<p dir="auto">I know of the C4D_Falloff and FalloffData classes, but it is a bit over my head how to utilize them within this particular application... and unfortunately there are no examples of what I'm trying to do in the documentation or anywhere online. I am writing a python modifier for sketch &amp; toon (which means it cannot be a plugin).</p>
<p dir="auto">More simply, I am trying to sample a MoGraph Effector's Falloff as the title states.</p>
<p dir="auto">2 inputs:<br />
• the Effector (BaseObject)<br />
• point coordinate (Vector)</p>
<p dir="auto">1 output:<br />
• falloff reading (Float between 0.0 - 1.0)</p>
<p dir="auto">This is something I've been wanting to be able to do for a long time in c4d python and have researched it multiple times at no avail, usually I end up resorting to roundabout setups to get things to work while in the midst of production. Thanks in advance for any leads.</p>
]]></description><link>http://developers.maxon.net/forum/topic/11147/sampling-the-falloff-of-a-mograph-effector-python-r19</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 09:05:17 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/11147.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Nov 2018 10:09:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sampling the falloff of a mograph effector? (python&#x2F;R19) on Wed, 28 Nov 2018 00:42:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m_adam">@<bdi>m_adam</bdi></a> Wow, this is truly great. What a fantastically written response, I really appreciate it! Learning a bunch from this example, way more than I asked for. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--smile" style="height:23px;width:auto;vertical-align:middle" title=":smile:" alt="😄" /></p>
<p dir="auto">Thanks again</p>
<p dir="auto">Jenny</p>
<p dir="auto">P.S. if only the py4d documentation had examples like this, we would all be better programmers <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f60b.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--yum" style="height:23px;width:auto;vertical-align:middle" title=":yum:" alt="😋" /></p>
]]></description><link>http://developers.maxon.net/forum/post/56499</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/56499</guid><dc:creator><![CDATA[jenandesign]]></dc:creator><pubDate>Wed, 28 Nov 2018 00:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to Sampling the falloff of a mograph effector? (python&#x2F;R19) on Wed, 09 Jan 2019 14:06:55 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/jenandesign">@<bdi>jenandesign</bdi></a>, first of all, welcome in the plugincafe community.</p>
<p dir="auto">No worry at all, since it's your first post, but I would like to point you about few rules in order to properly ask questions in this forum for future ones (I've set up this one).</p>
<ul>
<li><a href="https://developers.maxon.net/forum/topic/10953/how-to-post-questions" target="_blank" rel="noopener noreferrer nofollow ugc">How to Post Questions</a> (Especially the tagging system).</li>
<li><a href="https://developers.maxon.net/forum/topic/11004/q-a-new-functionality" target="_blank" rel="noopener noreferrer nofollow ugc">Q&amp;A New Functionality</a>.</li>
</ul>
<p dir="auto">With that's said. Regarding your question. I get it to work (a bit hacky) but it's working.<br />
When C4D render a scene, actually the whole scene is cloned in memory and then it renders this one. (It allow a user to still work on C4D while the other scene is rendering).<br />
So this render scene is read-only, you shouldn't modify at anytime anything in this scene, or you can screw up the render.<br />
Moreover in a shaderData, in order to optimize memory, only relevant information (aka polygon, UV) are copied. So you are losing your UserData.<br />
This means you have to find another way to find your effector.<br />
So the way I find to achieve what you want is to get the document from the object passed to the shader(the rendered document).<br />
Then in this document, I search for an effector called "Plain" (Not the most robust way but it's working).</p>
<p dir="auto">Then here the final code I put on the python color channel of a sketch and toon</p>
<pre><code>import c4d

def main():
    doc = op.GetDocument()
    effector = doc.SearchObject("Plain")
    if not effector: return c4d.Vector()
    
    eff =  c4d.modules.mograph.C4D_Falloff()
    if not eff: return c4d.Vector()
    eff.InitFalloff(bc=effector.GetData())

    eff.SetMg(effector.GetMg())
    eff.SetMode(effector[c4d.FALLOFF_MODE])

     # World position currently sampled
    value = eff.Sample(wPnt, False)
    return c4d.Vector(value)

</code></pre>
<p dir="auto">And the attached scene where a plain effector drives a mograph effector and the sketch and toon shader.<br />
<a href="https://developers.maxon.net/forum/assets/uploads/files/1542626487465-sketchandtoon.c4d" target="_blank" rel="noopener noreferrer nofollow ugc">0_1542626486830_SketchAndToon.c4d</a><br />
<img src="https://developers.maxon.net/forum/assets/uploads/files/1542626902838-sketchtoon-resized.jpg" alt="0_1542626902040_sketchtoon.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">If you have any questions, please let me know!<br />
Cheers,<br />
Maxime!</p>
]]></description><link>http://developers.maxon.net/forum/post/56411</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/56411</guid><dc:creator><![CDATA[m_adam]]></dc:creator><pubDate>Wed, 09 Jan 2019 14:06:55 GMT</pubDate></item><item><title><![CDATA[Reply to Sampling the falloff of a mograph effector? (python&#x2F;R19) on Sun, 18 Nov 2018 15:56:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi, here is a thread from the old forum: <a href="https://developers.maxon.net/forum/topic/362" target="_blank" rel="noopener noreferrer nofollow ugc">Sample Node With Python</a>.<br />
I don't know if there will be any solution for now.</p>
]]></description><link>http://developers.maxon.net/forum/post/56406</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/56406</guid><dc:creator><![CDATA[eZioPan]]></dc:creator><pubDate>Sun, 18 Nov 2018 15:56:49 GMT</pubDate></item></channel></rss>