PickObject

Introduced

v1.0

Description

Prompts the user to pick an object.

Tip: You can use "PickElement [object_name]" to set output parameters.

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

PickObject( LeftMessage, MiddleMessage, [PickedElement], [ButtonPressed], [ModifierPressed] );

Parameters

Parameter Type Description
LeftMessage String Status bar message for the left mouse button.
MiddleMessage String Status bar message for the middle mouse button.
PickedElement CollectionItem Returns the picked object.
ButtonPressed Long Returns the mouse button clicked by the user.

Possible Values:

Description:

0 Right mouse button (or the Esc key), which means the user aborted the picking session
1 Left mouse button
2 Middle mouse button
ModifierPressed Long Returns the modifier key pressed by the user.

Possible Values:

Description:

0 None
1 Shift modifier key
2 Ctrl modifier key
3 Shift-Ctrl modifier key

Examples

VBScript Example

' The following example will use "PickObject" to pick two objects 

' consecutively and will make the first object parent of the second one.

dim parent, child, button, modifier

NewScene

CreatePrim "Cone", "MeshSurface"

CreatePrim "Cylinder", "MeshSurface"

Translate , -0.118156772275078, -5.87851913444323, 0.587851913444323, _

		siRelative, siView, siObj, siXYZ

DeselectAll

PickObject "Select parent", "Select parent", parent, button

if button <> 0 then

	PickObject "Select child", "Select child", child, button, modifier

	if button <> 0 then

		if modifier = 0 then

			ParentObj parent, child

			logMessage "object " & parent & " is now parent of object " & child

		else

			ParentObj child, parent

			logMessage "object " & child & " is now parent of object " & parent

		end if

	end if

end if