SICreateLayerFromSelection

Introduced

v5.0

Description

Creates a new layer and add the selection to it but does not make the layer current.

Note: This command uses output arguments. C# and some scripting languages (such as JScript, PerlScript and Python) don't support arguments passed by reference so you need to use the best workaround for your situation:

For scripting languages this command returns an ISIVTCollection which you can use to get the output arguments.

For C# you can use the XSIApplication.ExecuteCommand method to call this command. ExecuteCommand packs the output arguments into a C# System.Object containing an Array of the output arguments (see Calling Commands from C#).

Scripting Syntax

SICreateLayerFromSelection( [PresetObj], [Name], [InputObjs], [Value] );

Parameters

Parameter Type Description
PresetObj String or a preset object (for example, an object obtained from SIGetPreset) Layer preset to use

Default Value: "Default_New_Layer"

Possible Values:

Description:

Default_New_Layer Default new layer
Name String Name of the new layer
InputObjs String List of objects to move to the layer

Default Value: Selected objects

Value Layer Returns the new layer

Examples

1. VBScript Example

'

' This example shows how to use the current selection

' to create a new layer and set that layer to current

'

NewScene , false

CreatePrim "Cylinder", "MeshSurface"

CreatePrim "Sphere", "MeshSurface"

ToggleSelection "cylinder", , True

' Now create the layer from the selection and make it current

SICreateLayerFromSelection , "LayerA", , oLayer

SetCurrentLayer oLayer

2. JScript Example

/*

	This example demonstrates how to create a new layer

	and set it to be the current layer

*/

// Setup

NewScene( null, false );

CreatePrim("Cylinder", "MeshSurface", null, null);

CreatePrim("Sphere", "MeshSurface", null, null);

ToggleSelection("cylinder", null, true);

// Get initial settings

checkCurrLayer();

// Make a new layer (it is *not* automatically set as current)

var oLayer = SICreateLayerFromSelection( null, "LayerA" )(0);

checkCurrLayer();

// Now explicitly set the new layer as current and check again

SetCurrentLayer( oLayer );

checkCurrLayer();

function checkCurrLayer()

{

	// What is the current layer?

	var oCurrLayer = GetCurrentLayer()(0);

	Application.LogMessage( "Current layer is....." + oCurrLayer );

}

// Expected result:

//INFO : Current layer is.....Layers.Layer_Default

//INFO : Current layer is.....Layers.Layer_Default

//INFO : Current layer is.....Layers.LayerA

3. Python Example

#

# This example demonstrates how to 

# create a layer from a group

#

app = Application

app.NewScene( "", 0 )

# Create two nulls 

app.GetPrim( "Null" )

app.GetPrim( "Null" )

# Add them to a new group

oGroup = app.CreateGroup( "NullsGroup", "null*" )

# Move the group to a new layer

ivtInfo = app.SICreateLayerFromSelection( "", "LayerNulls" )

oLayer = ivtInfo.Value( "Value" )

app.SetCurrentLayer( oLayer )

See Also

SICreateLayer SICreateLayer2 SICreateLayerFromSelection2 CreateLayer