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...





On 3/3/2015 3:19 PM, Matt Lind wrote:
You need a reference to the shader object, then use it's methods to test each parameter as shown here:
//-------- start of script (JScript) --------
var INDEX_SHADER_PORT_TYPE      = 0;
var INDEX_SHADER_PARAMETER_TYPE = 1;
GetShaderParameterInfo( Selection(0) );
function GetShaderParameterInfo( oObject )
{
    if ( !oObject.IsClassOf( siX3DObjectID ) ) {
        return;
    }
    var oMaterial        = oObject.Material;
    var oShaderParameter = oMaterial.Parameters( "surface" ).Source;
    if ( oShaderParameter ) {
        var oShader = oShaderParameter.Parent;
LogMessage( "Shader: " + oShader.FullName, siComment );
        var oParameters = oShader.Parameters;
        for ( var i = 0; i < oParameters.Count; i++ ) {
            var oParameter           = oParameters(i);
var oShaderParameterType = oShader.GetShaderParameterType( oParameter.ScriptName ); if ( oShaderParameterType.getItem( INDEX_SHADER_PORT_TYPE ) == true ) {
// input parameter
LogMessage( "INPUT: " + oParameter.ScriptName + ", " + oShaderParameterType.getItem( INDEX_SHADER_PARAMETER_TYPE ), siComment );
            } else {
// output parameter
LogMessage( "OUTPUT: " + oParameter.ScriptName + ", " + oShaderParameterType.getItem( INDEX_SHADER_PARAMETER_TYPE ), siComment );
            }
        }
    }
    return;
}
//--------- end of script ------------
Matt
Date: Tue, 03 Mar 2015 10:56:00 +0100
From: Jan Dubied <[email protected]>
Subject: Re: query shader parameters
To: [email protected]
hi  dan
unfortunately this gives an error:
# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 79, in <module>
#     if ( i.PortType == 0 ) :
#   File
"C:\Autodesk\Softimage_2015\Application\python\Lib\site-packages\win32com\client\dynamic.py",
line 516, in __getattr__
#     raise AttributeError("%s.%s" % (self._username_, attr))
# AttributeError: <unknown>.PortType
#  - [line 79]
i can't wrap my head around that. is there a wrong context?
if i print oNode i get:
# Sources.Materials.DefaultLib.Scene_Material.Phong
On 3/3/2015 10:50 AM, Dan Yargici wrote:
> for i in oNode.Parameters :
>     if ( i.PortType == 0 ) :
>         print i
--
------------------------------------------------------------------------
Jan Dubied
2D/3D Artist
*ON LINE VIDEO 46 AG*
Leutschenbachstr. 46 / 8050 Zurich / Switzerland
Phone +41 44 305 73 73 / Fax +41 44 305 73 00
www.onlinevideo.ch <http://www.onlinevideo.ch/>

--

------------------------------------------------------------------------

Jan Dubied
2D/3D Artist

*ON LINE VIDEO 46 AG*
Leutschenbachstr. 46 / 8050 Zurich / Switzerland
Phone +41 44 305 73 73 / Fax +41 44 305 73 00
www.onlinevideo.ch <http://www.onlinevideo.ch/>

Reply via email to