RemoveAllShadersFromCnxPoint

Introduced

v1.0

Description

Disconnects all shaders from the specified shader's connection points, without the need to know information about the connected shaders or if shaders are indeed connected.

The second argument allows the user to specify in detail what types of shader connections should be disconnected.

Note: Shaders that are not used anymore once disconnected are automatically deleted.

Scripting Syntax

RemoveAllShadersFromCnxPoint( [InputObjs], [Type] );

Parameters

Parameter Type Description
InputObjs String List of connection points.

Default Value: Current selection

Type siShaderCnxPointType Types of connection points to disconnect.

Default Value: siShaderCnxPointAll

Examples

VBScript Example

'

' This example demonstrates how to disconnect shaders on a scene object. It

' also shows how you can find out whether the object's material is connected

' to a shader or a texture.

'

sPath = XSIUtils.BuildPath( _

	Application.InstallationPath( siFactoryPath ), _

	"Data", "XSI_SAMPLES", "Scenes", "Rendering", _

	"Rendertree_Displacement_Cell.scn" _

)

OpenScene sPath, False

' Select the grid and get a pointer to it

SelectObj "grid"

Set oGrid = Selection(0)

' Output at this point (before removing the shaders):

' INFO : --------------------------------------------

' INFO : Found a shader on Surface

' INFO : Found a texture on Displacement

' INFO : Found a shader on Shadow

' INFO : Found a shader on Photon

displayDetails oGrid

' Disconnect the shaders, if any, connected to the grid material Volume,

' Displacement and Photon connection points. (Note that specifying the 

' Volume parameter is redundant in this case since it is not connected)

Set oCnxPoints = CreateObject( "XSI.Collection" )

oCnxPoints.Add oGrid.Material.Parameters( "volume" )

oCnxPoints.Add oGrid.Material.Parameters( "displacement" )

oCnxPoints.Add oGrid.Material.Parameters( "photon" )

RemoveAllShadersFromCnxPoint oCnxPoints, siShaderCnxPointAll

' Output at this point (notice that we only disconnected the shaders on the

' Displacement and Photon points so we still have shaders on Surface and

' Shadow):

' INFO : --------------------------------------------

' INFO : Found a shader on Surface

' INFO : Found a shader on Shadow

displayDetails oGrid

' ----------------------------------------------------------------------

function displayDetails( in_obj )

	Application.LogMessage "--------------------------------------------"

	' Look for each parameter that is connected to a shader and print its name

	For Each p In in_obj.Material.Parameters

		If TypeName( p.Source ) = "Shader" Then

			Application.LogMessage "Found a shader on " & p.Name

		ElseIf TypeName( p.Source ) = "Texture" Then

			Application.LogMessage "Found a texture on " & p.Name

		End If

	Next

end function

See Also

AddObjectsToShader RemoveObjectsFromShader ApplyShader RemoveShaderFromCnxPoint SIConnectShaderToCnxPoint