Dictionary.GetObject
 
 
 

Dictionary.GetObject

Description

Returns an existing object that corresponds to a full path name. In other words, it converts from a string representation of a Softimage object to the Object Model representation. This is similar to the GetValue command. However, in the case of Parameter objects, Dictionary.GetObject returnz the Parameter object and GetValue returns the parameter value (see the example below).

To convert in the other direction (from an Object Model representation to a string), use SIObject.FullName.

C# Syntax

Object Dictionary.GetObject( String in_bszObjectName, Boolean in_bThrowError );

Scripting Syntax

oReturn = Dictionary.GetObject( Pathname, [ThrowError] );

Return Value

The found object.

Parameters

Parameter Type Description
Pathname String Full path name of the object to find.
ThrowError Boolean By default Softimage will cause a script error if the object does not exist. If you are not sure if the object exists or not pass false as the value of this argument and Softimage will return null rather than throwing an error. This parameter is new starting with v5.0.

Default Value: true

Examples

1. VBScript Example

'
' Demonstrates usage of the Dictionary.GetObject method
'
' Clear the current scene to avoid name clashes and create
' a new cone named "foo"
deleteall false
CreatePrim "Cone", "MeshSurface", "foo"
' Find the subdivu parameter from the cone and set it to 10
Set oSubdivuParam = Dictionary.GetObject("foo.polymsh.geom.subdivu")
Application.LogMessage "Found a " & oSubdivuParam.type ' Outputs "Found a Parameter"
SetValue oSubdivuParam, 10
' Find the cone by its name and delete it
Set oCone = Dictionary.GetObject("foo")
Application.LogMessage "Found a " & oCone.type ' Outputs "Found a polymsh"
DeleteObj (oCone)

2. JScript Example

/*
        Demonstrates usage of the Dictionary.GetObject method
*/
NewScene(null,false);
var oModel = ActiveSceneRoot.AddModel(new ActiveXObject("XSI.Collection"),"MyMdl") ;
var oNull = oModel.AddNull( "MyN" );
var oSphere = oNull.AddGeometry("Sphere","MeshSurface","MyS");
// Expect "MyMdl.MyS"
Application.LogMessage( oSphere.FullName ) ;
// Retrieve the sphere again, this time via its string name
oSphere = Dictionary.GetObject( "MyMdl.MyS" )
// The sphere is actually nested underneath the Null so you can also specify it like this
oSphere = Dictionary.GetObject( "MyMdl.MyN.MyS" )
// Now look at one of the parameters under the sphere
// Expect "MyMdl.MyS.kine.local.posx"
Application.LogMessage( oSphere.Kinematics.Local.Parameters("posx").FullName );
// First move the sphere to a recognizable position
SetValue( "MyMdl.MyS.kine.local.posx", 7.5 )
// Calling GetValue will return the VALUE of posx parameter
var paramValue = GetValue( "MyMdl.MyS.kine.local.posx" ) ;
// Expect "number,7.5"
Application.LogMessage( typeof( paramValue ) + "," + paramValue);
// But calling Dictionary.GetObject will return the 
// actual Parameter object
var oParameter = Dictionary.GetObject( "MyMdl.MyS.kine.local.posx" )
// Expect "object,Parameter,7.5"
Application.LogMessage( typeof( oParameter ) + "," + Application.ClassName(oParameter) + "," + oParameter.Value ) ;

3. VBScript Example

'
' This example shows how to find an object by its name, and to create it if it doesn't already exists.  
' In this case we reuse the Annotation that has a specific name if it is already present at the scene root.
'
NewScene , false
dim strAnnotationName
strAnnotationName = "MyAnnotation"
set oObj = Dictionary.GetObject( strAnnotationName, false )
if TypeName( oObj ) = "Nothing" then
        set oObj = ActiveSceneRoot.AddProperty( "Annotation", false, strAnnotationName )
end if
InspectObj( oObj )

4. JScript Example

/*
        This example shows how to find an object by its name, and to create it if it doesn't already exists.  
        In this case we reuse the Annotation that has a specific name if it is already present at the scene root.
*/
var strAnnotationName = "MyAnnotation" ;
var oObj = Dictionary.GetObject( strAnnotationName, false ) ;
if ( !oObj ) {
        var oObj = ActiveSceneRoot.AddProperty( "Annotation", false, strAnnotationName ) ;
}
InspectObj( oObj )

5. Python Example

"""
Demonstrates Dictionary.GetObject() method with error handling
"""
Application.NewScene( "", False )
#Create a primitive
oCone = Application.CreatePrim("Cone", "MeshSurface", "", "")
# Use dictionary to locate the its render visibility
try:
        oRenderVisParam = Application.Dictionary.GetObject( "cone.visibility.rendvis", True )
        Application.LogMessage( "Parameter found. Value: " + str( oRenderVisParam.Value ) )
except:
        Application.LogMessage( "Parameter not found." )

See Also

GetValue SIObject Parameter