Introduced
1.0
Description
Connects a shader to the specified shader connection points.
Scripting Syntax
SIConnectShaderToCnxPoint( [Source], [InputObjs], [DeleteOnLastDisconnection] )
Parameters
|
Parameter |
Type |
Description |
|
Source |
Shader to connect Default Value: Current selection |
|
|
InputObjs |
List of shader connection points. Default Value: Current selection |
|
|
DeleteOnLastDisconnection |
True to delete existing shaders that are disconnected by this command. Default Value: True |
Return Value
Returns the connected shader.
Examples
VBScript Example
'
' This example creates a sphere, applies a lambert shader to it, prints out
' the list of connection points to that shader, connects the toon shader
' to the surface and shadow connection points and then prints the updated list.
'
' Create the sphere to which the shader will be connected
set oSphere = CreatePrim( "Sphere", "NurbsSurface" )
' Apply a lambert shader to instantiate the material
set oShader = SIApplyShader( InstallationPath( siFactoryPath ) _
& "\Data\DSPresets\Shaders\Material\Lambert.Preset", _
oSphere, "Christopher" )
' Convert the shader to a Shader object
set oShader = oShader(0)
' Print lambert shader info
printShaderInfo oShader
' Load a toon shader
CopyPaste , "Shaders\Material\Toon_Paint_Rounded.Preset", "TransientObjectContainer"
' For convenience, create a collection to hold the parameters
' to be disconnected (Surface and Shadow connection points).
set oCnxPoints = CreateObject( "XSI.Collection" )
oCnxPoints.Add oSphere & ".material.Surface"
oCnxPoints.Add oSphere & ".material.Shadow"
' Use that collection to connect the toon shader to the sphere
set oToony = SIConnectShaderToCnxPoint( "TransientObjectContainer.Toon_Paint_Rounded", oCnxPoints )
' Convert the shader to a Shader object
set oToony = oToony(0)
' Print toon shader info
printShaderInfo oToony
' This is a convenience routine that prints information about the shader
sub printShaderInfo( in_shader )
' From the shader object you can get the material it belongs to
set oMaterial = in_shader.Owners(0)
' Use the material to return the parameters that are connected and
' print out their names
for each p in oMaterial.Parameters
if TypeName( p.Source ) <> "Nothing" then
LogMessage p.ScriptName & " is connected to " & p.Source.Name
end if
next
end sub
' Output of the above script:
' ...before adding the toon shader
'INFO : "surface is connected to Christopher"
'INFO : "shadow is connected to Christopher"
'INFO : "Photon is connected to Christopher"
'
' ...after adding the toon shader
'INFO : "surface is connected to Toon_Paint_Rounded"
'INFO : "shadow is connected to Toon_Paint_Rounded"
'INFO : "Photon is connected to Christopher"
See Also
|
|
|
|
SOFTIMAGE|XSI v6.01