Parameter.ConnectFromFile

Introduced

v2.0

Description

Creates an object representing the parameter's DataSource from file and connects it to the parameter. This method can be used to connect a Shader to a parameter from the shader preset file name.

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

oReturn = Parameter.ConnectFromFile( FileName, [PrevDataSource] );

Return Value

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

Parameters

Parameter Type Description
FileName String The name of a file containing a data source definition (eg., a preset file -- see the list of Shader Presets)
PrevDataSource DataSource The previously connected DataSource if any; Nothing is returned it there is no previously connected DataSource.

Examples

VBScript Example

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

See Also

Parameter.Connect Parameter.ConnectFromPreset Parameter.ConnectFromProgID SceneItem.AddMaterial Parameter.Disconnect Shader Presets