Selecting through Scripting Commands

 
 
 

Everything that you can do manually in Softimage can be done through scripting commands, and selecting is no exception. You can change what's selected or find out what's selected.

Tip

This section only addresses how to work with the selection using scripting commands. For the more powerful object model and C++ API access, see Selection.

Getting the Current Selection

To find out what is currently selected, use the native Softimage GetValue command to return the SelectionList.

The SelectionList (Native Softimage Commands)

The SelectionList is a comma-delimited list of scene item names (strings) that represents all the objects that are currently selected.

To access the SelectionList with the GetValue command

	Set oReturn = GetValue("SelectionList")
	For Each r In oReturn 
		LogMessage r & " is an " & r.Type
	Next

Converting Selection Strings into Objects

When you use the Set keyword with certain native Softimage commands, the return value is automatically converted into a real object. This is very useful if, for example, you wanted to build a collection of objects from a string of Softimage object names, and especially if you want to use wildcards.

Note

If you are using a parameter string path with the GetValue command, the value type is returned; object string paths return proper objects.

To convert the current selection into an object collection

Set oRoot = ActiveProject.ActiveScene.Root
Set oSelection = GetValue( "SelectionList" )

For Each item In oSelection
	LogMessage item.Name
Next

To convert a wildcard string selection into a object collection

SelectObj "cube*" 
Set oSelection = Application.Selection

For Each item In oSelection
	LogMessage item.Name
Next

Changing the Selection

You can add items to the current selection through scripting or remove items from the current selection.

Selecting an Item

To select an element or parameter, use the SelectObj command with the corresponding name. For example:

SelectObj "Camera_Interest"

Adding an Item to the Selection

To add something to the current selection, use the AddToSelection command:

AddToSelection "Spot_Interest"

To select all cameras, lights, and 3D objects in a scene, use:

SelectAll

Removing an Item from the Selection

To remove something from the current selection, use the RemoveFromSelection command:

RemoveFromSelection "Scene.Scenecolors.litcol"

Clearing the Selection

To remove all items from the current selection, use:

DeselectAll

Picking

You can use the PickElement command to start an interactive picking session in a script.

Using Pick Element

The following example uses PickElement to prompt the user to pick a property. The returned variables are PickedElement, ButtonPressed, and ModifierPressed (for example, the Shift or Ctrl key). ButtonPressed is 0 if the users presses Esc or right-clicks to cancel the picking.

Dim PickedElement, ButtonPressed, ModifierPressed
call PickElement( "property", "Select a property", "Select a property",_
		PickedElement, ButtonPressed, ModifierPressed) 
if ButtonPressed <> 0 Then 
	'Test PickedElement to see if it's a property then
	'Do something with PickedElement
End if