v6.0
Removes a resolution to a referenced Model. A referenced model can have an
unlimited number of resolutions. Each resolution has a name and a
file.
Warning: If you try to remove the active resolution, the command
raises an Invalid Argument error. You can activate a different
resolution via the "Active Resolution" parameter on the referenced
model.
RemoveRefModelResolution( Model, ResolutionName, [Confirm] ); |
| Parameter | Type | Description |
|---|---|---|
| Model | String | The model containing the resolution you want to remove.
Default Value: Current selection |
| ResolutionName | String | The name of the resolution. |
| Confirm | Boolean | This argument will indicate if you want to get a confirmation
message before continuing with the resolution. This can be useful
when writing scripts in order to avoid stopping the script.
Default Value: False |
'
' This example illustrates how to add and remove resolutions on a reference model. It also demonstrates
' how to navigate through the resolution information on a reference model (see the convenience functions
' at the bottom of the example, especially GetAllResolutions).
'
' Import a referenced model.
NewScene , false
sModelPath = XSIUtils.BuildPath( Application.InstallationPath(siFactoryPath), _
"Data", "XSI_SAMPLES", "Models", "ManSkeleton_Basic.emdl" )
ImportModel sModelPath, , true
' Add a new resolution
set oRefModel = Application.ActiveSceneRoot.Models.Item(0)
AddRefModelResolution oRefModel, "MyRes", sModelPath
' Now remove the original resolution
iTargetRes = GetResolutionIndexByName( oRefModel, "res1" )
if iTargetRes > -1 then
iCurrentRes = oRefModel.NestedObjects("Active Resolution").Value
if iCurrentRes = iTargetRes then
' Change the active resolution to the new one and remove the original
oRefModel.NestedObjects("Active Resolution").Value = iTargetRes + 1
RemoveRefModelResolution oRefModel, "res1", true
end if
' Display again the resolutions
LogResolutions oRefModel
end if
' Expected results:
' INFO : res0
' INFO : file =
' INFO : name = Offloaded
' INFO : res1
' INFO : file = Models\ManSkeleton_Basic.emdl
' INFO : name = res1
' INFO : res2
' INFO : file = Models\ManSkeleton_Basic.emdl
' INFO : name = MyRes
' INFO : res0
' INFO : file =
' INFO : name = Offloaded
' INFO : res1
' INFO : file = Models\ManSkeleton_Basic.emdl
' INFO : name = MyRes
'
' These are convenience functions that do most of the work of navigating through
' the resolutions information nested under each reference model. The resolutions
' info is never displayed in the UI, but you can think of its structure like so:
'
' ReferenceModel (model)
' - Resolutions (special container)
' - res0 (compound parameter)
' - File parameter (eg., "<installationpath>/Data/XSI_SAMPLES/Models/ManSkeleton_Basic.emdl")
' - Name parameter (eg., "MyRes")
' + res1
' ...
' + resN
'
' In order to access this info you need to use the SIObject.NestedObjects property
' on the ReferenceModel, the Resolutions container, and then each resolution parameter.
'
function GetAllResolutions( in_oRefModel )
for each oCurrentContainer in in_oRefModel.NestedObjects
if oCurrentContainer.Name = "Resolutions" then
set GetAllResolutions = oCurrentContainer.NestedObjects
exit function
end if
next
end function
'
' Logs the file and name values of each resolution to history
'
sub LogResolutions( in_oRefModel )
' Visit each resolution and find its name and file info
set oResolutions = GetAllResolutions( in_oRefModel )
for each oResolutionParameter in oResolutions
Application.LogMessage oResolutionParameter.Name
' The file and name parameters are nested under the compound resolution parameter
for each oResInfoParam in oResolutionParameter.NestedObjects
Application.LogMessage " " & oResInfoParam.Name & " = " & oResInfoParam.Value
next
next
end sub
'
' Returns the index number of the resolution given its name
'
function GetResolutionIndexByName( in_oModel, in_sResName )
' Visit each resolution and check its name against the specified name
set oResolutions = GetAllResolutions( in_oModel )
for i=0 to oResolutions.Count
set oResolutionParameter = oResolutions(i)
if oResolutionParameter.NestedObjects("name").Value = in_sResName then
GetResolutionIndexByName = i
exit function
end if
next
' If not found, return a negative value
GetResolutionIndexByName = -1
end function
|