For starters, I'd name your variables to reflect what they are. Doing so
will make it easier to follow the logic and spot the problem.
Look up ShaderParameter.GetShaderParameterType() in the SDK manuals and
you'll see the method returns an array. the first index of that array is a
boolean indicating whether the parameter is an input parameter (true) or
output parameter (false). the 2nd index of the array is an enum which
indicates the parameter type (float, integer, color, vector, ...). In my
example code, I defined two constants to specify which array index to lookup
(INDEX_SHADER_PARAMETER_TYPE, INDEX_SHADER_PORT_TYPE). I did that to make
the code easier to read and understand. Also to avoid making stupid
mistakes if the array needs to be accessed in many different areas of the
code. Not really necessary in a snippet this small, but useful in larger
scripts and good practice.
The '.getItem()' method is specific to JScript as all Softimage methods
returning arrays in the JScript script engine return them as VBSafeArray
objects. Instead of using the usual array[index] notation, you must use
array.getItem(index) method. However, if you're using Python, you don't use
the .getItem() method at all. You use whatever is normally used for
indexing a python array.
Matt
Date: Tue, 03 Mar 2015 16:33:58 +0100
From: Jan Dubied <j.dub...@onlinevideo.ch>
Subject: Re: query shader parameters
To: softimage@listproc.autodesk.com
hi matt
thank you
i tried to translate to python:
this part works and prints:
for i in oNode.Parameters :
oNodeParameterType = oNode.GetShaderParameterType( i.ScriptName )
print oNodeParameterType
# (True, 1)
# (True, 3)
# (True, 1)
# (True, 1)
# (False, 4)
now, how to get the first thing? (true/false)
this does not work:
for i in oNode.Parameters :
oNodeParameterType = oNode.GetShaderParameterType( i.ScriptName )
print oNodeParameterType
if oNodeParameterType.getItem( 0 ) == true:
print i
else:
print str(i) + "OUTPUT"
# ERROR : Traceback (most recent call last):
# File "<Script Block >", line 84, in <module>
# if oNodeParameterType.getItem( 0 ) == true:
# AttributeError: 'tuple' object has no attribute 'getItem'
# - [line 84]
i think i'm close now... i hope so...