v6.0
リファレンス Model から解像度を削除します。 リファレンス モデルには、解像度を無制限に設定できます。 各解像度には、名前とファイルがあります。
警告: 有効な解像度を削除しようとすると、「Invalid Argument」エラーが発生します。 リファレンス モデルの[有効解像度]パラメータを介して、別の解像度を有効にすることができます。
RemoveRefModelResolution( Model, ResolutionName, [Confirm] ); |
| パラメータ | タイプ | 説明 |
|---|---|---|
| Model | 文字列 |
削除する解像度を含むモデル。 デフォルト値: 現在選択されている値 |
| ResolutionName | 文字列 | 解像度の名前。 |
| Confirm | Boolean |
この引数は、解像度の処理を続行する前にユーザが確認メッセージを受け取るかどうかを示します。 この引数は、スクリプトを停止させないようにスクリプトを作成する場合に便利です。
デフォルト値: 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 |