SIConnectShaderToCnxPoint

Introduced

v1.0

Description

Connects a shader to the specified shader connection points.

Scripting Syntax

oReturn = SIConnectShaderToCnxPoint( [Source], [InputObjs], [DeleteOnLastDisconnection] );

Return Value

Returns an XSICollection that contains the newly connected shader(s).

Parameters

Parameter Type Description
Source String Shader to connect

Default Value: Current selection

InputObjs String List of shader connection points.

Default Value: Current selection

DeleteOnLastDisconnection Boolean True to delete existing shaders that are disconnected by this command.

Default Value: True

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

NewScene , false

set oSphere = CreatePrim( "Sphere", "NurbsSurface" )

' Apply a lambert shader to instantiate the material

sPresetPath = XSIUtils.BuildPath(_

	Application.InstallationPath(siFactoryPath), _

	"Data", "DSPresets", "Shaders", "Material", "Lambert.Preset" _

)

set oShader = SIApplyShader( sPresetPath, oSphere, "Christopher" )

' Convert the shader to a Shader object 

set oShader = oShader(0)

' Print lambert shader info 

printShaderInfo oShader

' Load a toon shader

CreateShaderFromPreset "Shaders\Material\Toon_Paint_Rounded.Preset", "Sources.Materials.DefaultLib.Material"

' 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( "Sources.Materials.DefaultLib.Material.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

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

' INFO : shadow is connected to Phong

' INFO : Photon is connected to Lambert

See Also

AddObjectsToShader RemoveObjectsFromShader ApplyShader RemoveShaderFromCnxPoint RemoveAllShadersFromCnxPoint