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 <j.dub...@onlinevideo.ch>
Subject: Re: query shader parameters
To: softimage@listproc.autodesk.com

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

Reply via email to