'
' This example shows a typical use of XSIFactory.CreateObject to create a temporary
' CustomProperty object used as the UI for an Import or Export operation.
'
' There are two routines. DoScanUI is a user-friendly version that lets the user pick
' the options for the operation via a temporary custom pset. It then calls DoScanLowLevel
' which does the actual operation without any UI.
'
DoScanUI Application.InstallationPath( siUserPath ), false
sub DoScanUI( in_defaultScanLocation, in_bRecursive )
if NOT Application.Interactive then
' If you want your script to work in batch mode you could skip the modal dialog box and just
' use the default values. But it would be clearly code to call DoScanLowLevel directly.
DoScanLowLevel in_defaultScanLocation, in_bRecursive
exit sub
end if
' This CustomProperty is not part of the scene
' and will not be persisted
set oTempPSet = XSIFactory.CreateObject( "CustomProperty" )
oTempPSet.Name = "Scan Options"
oTempPSet.AddParameter3 "ScanFolder", siString
oTempPSet.AddParameter3 "Recursive", siBool, , , , false
' Establish the default values in the Custom PSet
oTempPSet.ScanFolder.Value = in_defaultScanLocation
oTempPSet.Recursive.Value = in_bRecursive
' Build a custom layout
set oLayout = oTempPSet.PPGLayout
oLayout.AddItem "ScanFolder", "Scan Folder", siControlFolder
oLayout.AddItem "Recursive"
' Show the custom ui, Softimage is frozen until the user closes the dialog
bCancel = InspectObj( oTempPSet,,,siModal,false )
if bCancel then
Logmessage "Operation cancelled"
else
'Read the values from the pset
strScanLocation = oTempPSet.ScanFolder.Value
bRecursive = oTempPSet.Recursive.Value
DoScanLowLevel strScanLocation, bRecursive
end if
' No need to call DeleteObj
end sub
sub DoScanLowLevel( in_folder, in_bRecursive )
' Do the scanning operation not actually implemented in this example)
strMsg = "Doing "
if in_bRecursive then
strMsg = strMsg & "recursive "
end if
Application.LogMessage strMsg & "scan of " & in_folder
end sub |