RemoveShaderFromCnxPoint

Introduced

v1.0

Description

Disconnects a shader from the specified shader connection points.

Scripting Syntax

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

Return Value

Returns the disconnected shader.

Parameters

Parameter Type Description
Source String Shader to disconnect.

Default Value: Current selection

InputObjs String List of 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, disconnects the shadow and

' photon connection points from the shader 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 shader info (before disconnecting)

printShaderInfo oShader

' For convenience, create a collection to hold the parameters

' to be disconnected (Shadow and Photon connection points).

set oCnxPoints = CreateObject( "XSI.Collection" )

oCnxPoints.Add oSphere & ".material.Shadow"

oCnxPoints.Add oSphere & ".material.Photon"

' Use that collection to disconnect the shader from the material 

RemoveShaderFromCnxPoint oShader, oCnxPoints

' Print shader info (after disconnecting)

printShaderInfo oShader

' 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 disconnecting

'INFO : "surface is connected to Christopher"

'INFO : "shadow is connected to Christopher"

'INFO : "Photon is connected to Christopher"

'

' ...after disconnecting

'INFO : "surface is connected to Christopher"

See Also

AddObjectsToShader RemoveObjectsFromShader ApplyShader RemoveAllShadersFromCnxPoint SIConnectShaderToCnxPoint