<?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[find material slot for shader]]></title><description><![CDATA[<p dir="auto"><em>On 26/08/2018 at 07:20, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">hi there,</p>
<p dir="auto">is it possible to find the shader slot in a material for a given shader?</p>
<p dir="auto">i.e. if i have this setup<br />
Mat[c4d.MATERIAL_USE_COLOR] = some_shader</p>
<p dir="auto">can i find c4d.MATERIAL_USE_COLOR if i have only Mat and some_shader?</p>
<p dir="auto">--&gt; I'd need something like:<br />
findSlot(Mat, some_shader)  # 2000 (c4d.MATERIAL_USE_COLOR)</p>
<p dir="auto">best, index</p>
]]></description><link>http://developers.maxon.net/forum/topic/10934/14391_find-material-slot-for-shader</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 14:24:14 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/10934.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Sep 2018 10:59:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to find material slot for shader on Sat, 01 Sep 2018 10:59:07 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 28/08/2018 at 02:22, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">tx andreas, an exciting world <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">i got a bit further with my findSlot(Mat, some_shader) <br />
and dont understand why i get Attribute Errors when i iterate over a bc:</p>
<p dir="auto">def findSlot_v1(sh) : # sh = some shader already inserted in a material slot<br />
bc = mat.GetDataInstance()<br />
for i, v in bc:<br />
print i, v<br />
if v == sh: return i</p>
<p dir="auto">--&gt; AttributeError: Parameter value not accessible (object unknown in Python)</p>
<p dir="auto">def findSlot_v2(sh) : # sh = some shader already inserted in a material slot<br />
bc = mat.GetDataInstance()<br />
for i, v in bc:<br />
try:<br />
if v == sh: return i<br />
except AttributeError:<br />
pass</p>
<p dir="auto">--&gt; AttributeError: Parameter value not accessible (object unknown in Python)</p>
<p dir="auto">def findSlot_v3(sh) : # sh = some shader already inserted in a material slot<br />
bc = mat.GetDataInstance()<br />
for i in range(len(bc) - 1) :<br />
try:<br />
index = bc.GetIndexId(i)<br />
if op[index] == sh: return index<br />
except AttributeError:<br />
pass</p>
<p dir="auto">--&gt; this finally works</p>
<p dir="auto">but could anybody tell me why i get these strange AttributeErrors ?</p>
<p dir="auto">the first version is straight from the book:<br />
<a href="https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.%5C__iter%5C_%5C_" target="_blank" rel="noopener noreferrer nofollow ugc">https://developers.maxon.net/docs/py/2023_2/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.\__iter\_\_</a></p>
<p dir="auto">and... i guess there no nicer/faster solution without iterating over the complete bc?</p>
<p dir="auto">best, index</p>
]]></description><link>http://developers.maxon.net/forum/post/55501</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55501</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to find material slot for shader on Sat, 01 Sep 2018 10:59:05 GMT]]></title><description><![CDATA[<p dir="auto"><em>On 27/08/2018 at 11:29, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi index,</p>
<p dir="auto">welcome to the Plugin Café forums <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":slightly_smiling_face:" alt="🙂" /></p>
<p dir="auto">Unfortunately no, there is no such function. If the shader setup is simple enough, you could just have an array with parameter IDs and then compare the linked shaders in your own FindSlot() function. A bit more complicated it gets, if the shader setups can be more complicated, including sub-shaders, like e.g. layer shader. Then you have to additionally iterate the shader tree for each slot.</p>
]]></description><link>http://developers.maxon.net/forum/post/55500</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/55500</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Sat, 01 Sep 2018 10:59:05 GMT</pubDate></item></channel></rss>