You can add or remove items from the Selection object/class using the techniques outlined in these sections:
• Selecting a Single Item (Adding to the Selection)
• Deselecting Specific Items (Removing from the Selection)
• Deselecting Everything (Clearing the Selection)
Selecting a Single Item (Adding to the Selection)
- Use Selection.Add (object model) or Selection::Add (C++ API) which take an object pointer as input:
// C++ API Application app; Model root = app.GetActiveSceneRoot(); X3DObject myGrid; root.AddGeometry( L"Grid", L"NurbsSurface", L"myGrid", myGrid ); Selection sel( app.GetSelection() ); sel.Add( myGrid );
// C#
CXSIApplication app = new CXSIApplication();
Model root = app.ActiveSceneRoot;
X3DObject myGrid = root.AddGeometry("Grid", "NurbsSurface", "myGrid");
Selection sel = app.Selection;
sel.Add(myGrid, siSelectMode.siSelectDefault);
// JScript var myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ); Selection.Add( myGrid );
' VBScript set myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) Selection.Add myGrid
# Python app = Application myGrid = app.ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) app.Selection.Add( myGrid )
# Perl my $app = $Application; my $myGrid = $app->ActiveSceneRoot->AddGeometry( "Grid", "NurbsSurface" ); $app->Selection->Add( $myGrid );
Related Scripting Commands
• SelectTree, SelectBranch, SelectModel
• GrowSelection, InvertSelection
• SelectAllUsingFilter, SelectGeometryComponents, SelectAdjacent
• ToggleSelection, ToggleObjectComponentSelectionFilter, ToggleParameterValue, SetAndToggleSelection
• ActivateElements, SetActiveElements, ToggleActiveElements, SetAndToggleActiveElements
• ConvertSelection, ConvertSelectionToEdges, ConvertSelectionToPoints, ConvertSelectionToPolygons
- Use Selection.SetAsText (object model) or Selection::SetAsText (C++ API) which take a String Expression as input:
// C++ API Application app; Model root = app.GetActiveSceneRoot(); X3DObject myGrid; root.AddGeometry( L"Grid", L"NurbsSurface", L"myGrid", myGrid ); X3DObject myCylinder; root.AddGeometry( L"Cylinder", L"MeshSurface", L"myCylinder", myCylinder ); Selection sel( app.GetSelection() ); sel.SetAsText( L"myGrid,myCylinder" );
// C#
CXSIApplication app = new CXSIApplication();
Model root = app.ActiveSceneRoot;
X3DObject myGrid = root.AddGeometry("Grid", "NurbsSurface", "myGrid");
X3DObject myCylinder = root.AddGeometry("Cylinder", "MeshSurface", "myCylinder");
Selection sel = app.Selection;
sel.SetAsText(myGrid.Name + "," + myCylinder.Name);
// JScript var myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ); var myCylinder = ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ); Selection.SetAsText( myGrid + "," + myCylinder );
' VBScript set myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) set myCylinder = ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ) Selection.SetAsText myGrid & "," & myCylinder
# Python app = Application myGrid = app.ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) myCylinder = app.ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ) app.Selection.SetAsText( "%s,%s" %(myGrid.Name,myCylinder.Name) )
# Perl my $app = $Application; my $myGrid = $app->ActiveSceneRoot->AddGeometry( "Grid", "NurbsSurface" ); my $myCylinder = $app->ActiveSceneRoot->AddGeometry( "Cylinder", "MeshSurface" ); $app->Selection->SetAsText( $myGrid->Name.",".$myCylinder->Name );
Related Scripting Commands
• SelectTree, SelectBranch, SelectModel
• GrowSelection, InvertSelection
• SelectAllUsingFilter, SelectGeometryComponents, SelectAdjacent
• ToggleSelection, ToggleObjectComponentSelectionFilter, ToggleParameterValue, SetAndToggleSelection
• ActivateElements, SetActiveElements, ToggleActiveElements, SetAndToggleActiveElements
• ConvertSelection, ConvertSelectionToEdges, ConvertSelectionToPoints, ConvertSelectionToPolygons
Deselecting Specific Items (Removing from the Selection)
- Use Selection.Remove (object model) or Selection::Remove (C++ API) which take an object pointer as input:
// C++ API Application app; Model root = app.GetActiveSceneRoot(); X3DObject myGrid; root.AddGeometry( L"Grid", L"NurbsSurface", L"myGrid", myGrid ); X3DObject myCylinder; root.AddGeometry( L"Cylinder", L"MeshSurface", L"myCylinder", myCylinder ); Selection sel( app.GetSelection() ); sel.SetAsText( L"myGrid,myCylinder" ); sel.Remove( myGrid ); // leaves only 'myCylinder' selected
// C#
CXSIApplication app = new CXSIApplication();
Model root = app.ActiveSceneRoot;
X3DObject myGrid = root.AddGeometry("Grid", "NurbsSurface", "myGrid");
X3DObject myCylinder = root.AddGeometry("Cylinder", "MeshSurface", "myCylinder");
Selection sel = app.Selection;
sel.SetAsText(myGrid.Name + "," + myCylinder.Name);
sel.Remove(myGrid, siSelectMode.siSelectDefault); // leaves only 'myCylinder' selected
// JScript var myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ); var myCylinder = ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ); Selection.SetAsText( myGrid + "," + myCylinder ); Selection.Remove( myGrid ); // leaves only 'myCylinder' selected
' VBScript set myGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) set myCylinder = ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ) Selection.SetAsText myGrid & "," & myCylinder Selection.Remove myGrid ' leaves only 'myCylinder' selected
# Python app = Application myGrid = app.ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) myCylinder = app.ActiveSceneRoot.AddGeometry( "Cylinder", "MeshSurface" ) app.Selection.SetAsText( "%s,%s" %(myGrid.Name,myCylinder.Name) ) app.Selection.Remove( myGrid ) # leaves only 'myCylinder' selected
# Perl my $app = $Application; my $myGrid = $app->ActiveSceneRoot->AddGeometry( "Grid", "NurbsSurface" ); my $myCylinder = $app->ActiveSceneRoot->AddGeometry( "Cylinder", "MeshSurface" ); $app->Selection->SetAsText( $myGrid->Name.",".$myCylinder->Name ); $app->Selection->Remove( $myGrid ) # leaves only 'myCylinder' selected
Related Scripting Commands
• ShrinkSelection, InvertSelection
• DeactivateElements, ToggleActiveElements, SetAndToggleActiveElements
Deselecting Everything (Clearing the Selection)
- Use Selection.Clear (object model) or Selection::Clear (C++ API):
// C++ API Selection sel( Application().GetSelection() ); sel.Clear();
// C# CXSIApplication app = new CXSIApplication(); Selection sel = app.Selection; sel.Clear();
// JScript Selection.Clear();
' VBScript Selection.Clear
# Python Application.Selection.Clear()
# Perl $Application->Selection->Clear();
Related Scripting Commands
• ShrinkSelection, InvertSelection
• DeactivateElements, ToggleActiveElements, SetAndToggleActiveElements
SOFTIMAGE|XSI v6.01