On 28/08/2018 at 02:22, xxxxxxxx wrote:
tx andreas, an exciting world 
i got a bit further with my findSlot(Mat, some_shader)
and dont understand why i get Attribute Errors when i iterate over a bc:
def findSlot_v1(sh) : # sh = some shader already inserted in a material slot
bc = mat.GetDataInstance()
for i, v in bc:
print i, v
if v == sh: return i
--> AttributeError: Parameter value not accessible (object unknown in Python)
def findSlot_v2(sh) : # sh = some shader already inserted in a material slot
bc = mat.GetDataInstance()
for i, v in bc:
try:
if v == sh: return i
except AttributeError:
pass
--> AttributeError: Parameter value not accessible (object unknown in Python)
def findSlot_v3(sh) : # sh = some shader already inserted in a material slot
bc = mat.GetDataInstance()
for i in range(len(bc) - 1) :
try:
index = bc.GetIndexId(i)
if op[index] == sh: return index
except AttributeError:
pass
--> this finally works
but could anybody tell me why i get these strange AttributeErrors ?
the first version is straight from the book:
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/BaseContainer/index.html?highlight=basecontainer#BaseContainer.__iter__
and... i guess there no nicer/faster solution without iterating over the complete bc?
best, index