CreateObjectFromPreset

Introduced

1.0

Description

Creates and returns a new object based on a preset. The object is created in the TransientObjectContainer meaning that it is not persisted in the scene or visible in the scene explorer. This area is flushed each time a new scene is loaded. This command can be useful for creating temporary CustomProperty objects as shown in the example below. It can also be used during the construction of a render tree, but normally Parameter.ConnectFromPreset would be used instead.

Scripting Syntax

CreateObjectFromPreset( PresetObj, [Name] )

Parameters

Parameter

Type

Description

PresetObj

String

Preset object or full path of the preset file. See Constraint Presets, Model Presets, Operator Presets, Pass Presets, Primitive Presets, Property Presets, and Shader Presets

Name

String

Name to give the created object

Return Value

Returns the newly created object.

Examples

VBScript Example

option explicit
'
'  Example of creating a temporary custom property (aka custom pset).
'  This can be useful for showing a temporary yet non-modal custom pset
'  to the user.  The user doesn't have to close the PPG immediately
'  yet the object does not clutter up the scene file.
'

'Demonstrate how you can use it to create a built in custom pset
dim oAnnotation
set oAnnotation = CreateTemporaryCustomPSet( "Annotation", siFactoryPath, "MyA" ) 
InspectObj oAnnotation


'Assumes that you have installed the PSetUIDemo.spdl example
InspectObj CreateTemporaryCustomPSet( "PSetUIDemo", siUserPath, "" )


' Function CreateTemporaryCustomPSet
' Creates a temporary custom property set.  This does not appear in the scene explorer and you do not have to
' worry about deleting it.
'
' in_PresetName - Name of the preset, which normally matches the name of the spdl file.  Do not include the extension
' in_PresetLocation - See siInstallationPath in reference for possible values (e.g. siUserPath, siUserAddonPath etc)
' in_CustomPSetName - Desired name for the new object, or leave empty for default behavior
'
' Return Value: newly created custom pset

function CreateTemporaryCustomPSet( in_PresetName, in_PresetLocation, in_CustomPSetName )
   dim oPSet

   if ( in_CustomPSetName = "" ) then
       in_CustomPSetName = in_PresetName
   end if

   on error resume next
   set oPSet = Dictionary.GetObject( "TransientObjectContainer." & in_CustomPSetName )
   on error goto 0

   if (typename(oPSet) = "customparamset") then
       'We created have a temporary pset by this name so return it
       set CreateTemporaryCustomPSet = oPSet
       exit function

   end if

   'Otherwise create a new one

   'We have to specify the full path
   dim presetFullPath
   presetFullPath = Application.InstallationPath( in_PresetLocation ) & _
       "/Data/DSPresets/Properties/" & _
       in_PresetName &_
       ".Preset"

   set CreateTemporaryCustomPSet = CreateObjectFromPreset( presetFullPath, in_CustomPSetName )

end function

See Also

XSIFactory.CreateObjectFromPreset

CreatePreset

LoadPreset

SavePreset

SIGetPreset

SILoadPreset

SIAddPropEx

 



SOFTIMAGE|XSI v6.01     

Return to Softimage XSI Index