ConnectFromPreset (Parameter)

Introduced

2.0

Description

Creates a DataSource object from a preset name and connects it to the parameter. This method can be used to connect a shader to a parameter from the shader preset, in which case the Shader object is returned.

Note: This method uses output arguments. C# and some scripting languages (such as JScript, PerlScript and Python) don't support arguments passed by reference. Normally for scripting you can get the output arguments via the ISIVTCollection, but this method already returns a value (C# cannot use this workaround because it does not have access to the ISIVTCollection).

The only available workaround in this case is to create a VBScript custom command which returns both the output arguments and the return value in one array. For details, see What Happens when the Function Already Returns a Value?.

Scripting Syntax

Parameter.ConnectFromPreset( Name, Family, [PrevDataSource] )

C# Syntax

DataSource Parameter.ConnectFromPreset( String in_PresetName, String in_PresetFamily, Object& out_pvPrevDataSource );

Parameters

Parameter

Type

Description

Name

String

The name of the preset (see the list of Shader Presets)

Family

siFamily

The family name of the preset

PrevDataSource [out]

DataSource object

The previously connected datasource if any; Nothing is returned it there is not previously connected datasource.

Return Value

The newly created object of a type based on the preset used, for example a Shader (see the DataSource topic).

Examples

VBScript Example

'
' This illustrates how to connect a shader from a shader preset.
'
NewScene , false
set grid = Application.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" )
set mat = grid.AddMaterial
set surface = mat.Parameters("Surface")
set phong = surface.ConnectFromPreset( "Phong","Material Shaders" )
set shadow = mat.Parameters("Shadow")
call shadow.Connect( phong )
set photon = mat.Parameters("Photon")
call photon.Connect( phong )

See Also

Parameter.Connect

Parameter.ConnectFromFile

Parameter.ConnectFromProgID

SceneItem.AddMaterial

Parameter.Disconnect

Shader Presets

 

 



Autodesk Softimage v7.5