Avoiding Unnecessary Conversions between String Expressions and Object Pointers

 
 
 

String Expressions are used mostly by scripting commands as a way of identifying scene items; object pointers are the preferred type of variable for the object model.

	' Get a pointer to the camera
	set c = ActiveSceneRoot.FindChild( "Camera" )

	' We can save the name of the object as a string in different ways
	' 	Object -> String Expression
	s1 = GetValue( c )
	s2 = c.Name

	' As can converting the object's name to an object pointer 
	' 	String Expression -> Object
	set o1 = GetValue( s1 )
	set o2 = Dictionary.GetObject( s2 )

	LogMessage "c = " & TypeName(c)
	LogMessage "s1 = " & TypeName(s1)
	LogMessage "s2 = " & TypeName(s2)
	LogMessage "o1 = " & TypeName(o1)
	LogMessage "o2 = " & TypeName(o2)

	'INFO : c = Camera
	'INFO : s1 = String
	'INFO : s2 = String
	'INFO : o1 = Camera
	'INFO : o2 = Camera

While you can convert fairly easily between String Expressions and object pointers in the Softimage SDK, this can reduce performance and it's not generally necessary. For example, if you want to use a scripting command that takes a String Expression as input to identify a scene element, you don't have to convert your object pointer to a string: the default property on most simple objects is the Name (SIObject) * property, so you can just pass the object pointer to the command.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License