RenamePropAndRebind

導入

v3.5

詳細

プロパティへのリファレンスをすべて保持しつつプロパティ名を変更します。 たとえば、UV プロパティの名前が変更されると、オブジェクト内に存在する全シェーダ、レンダマップ、テクスチャマップおよびマテリアルのプロパティへのリファレンスをすべて更新します。これにより、名称変更後もそのリファレンスは同じプロパティを参照します。

スクリプト構文

RenamePropAndRebind( [Properties], NewName, [UpdateRefs], [UpdateWildcards] );

パラメータ

パラメータ タイプ 詳細
Properties Property 名前を変更するプロパティ

デフォルト値: 現在選択されている値

NewName 文字列 プロパティの新しい名前

デフォルト値:何も指定されない場合は、このプロパティの新しい名前が自動的に作成されます。

UpdateRefs ブール True の場合は、シェーダ、マテリアル、レンダマップなどのプロパティへのリファレンスを更新します。

デフォルト値: true

UpdateWildcards ブール True の場合は、ワイルドカードを含むリファレンスを更新します(例: uvprop*)。

デフォルト値: false

VBScript の例

'-------------------------------------------------------------------------------
'
' This example demonstrates how to rename a texture map when it is applied to a 
' whole group (consisting of two spheres).
'
NewScene , false
' Create the smaller ball
Set oBall_1 = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "smBall" )
oBall_1.radius.Value = 2
' Create the larger ball
Set oBall_2 = ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "lgBall" )
oBall_2.radius.Value = 3
' Create a group based on the selection (the two balls)
Selection.Clear
For Each mbr In ActiveSceneRoot.Children.Filter( , siMeshFamily )
        LogMessage "Adding " & mbr & " to the selection."
        Selection.Add mbr
Next
Set oGroup = ActiveSceneRoot.AddGroup( Selection, "Onion" )
' Now create a texture map for the whole group (notice that we don't need to 
' specify input objects because we are using the current selection)
Set oMapMembers = Create2DMapWithProjection( oGroup )
' Are these the same members as our selection?
LogMessage "The texture map was added to " & oMapMembers.GetAsText & "......."
' Find all texture maps in the scene
checkForMaps
' Rename the texture map 
RenamePropAndRebind oGroup.Properties( "Texture_Map" ), "Superciliousness", True
' Check to make sure we renamed all texture maps in the scene
checkForMaps
'-------------------------------------------------------------------------------
function checkForMaps()
        For Each mesh_item In ActiveSceneRoot.Children.Filter( , siMeshFamily )
                For Each prop in mesh_item.Properties
                        If (prop.Name = "Superciliousness") _
                        OR (prop.name = "Texture_Map") Then
                                LogMessage "Found " & prop.Name _
                                        & " under " & mesh_item.Name
                        End If
                Next
        Next
end function
'-------------------------------------------------------------------------------
' Output of above script:
'INFO : "Adding smBall to the selection."
'INFO : "Adding lgBall to the selection."
'
'INFO : "The texture map was added to Onion.Texture_Map......."
'
'INFO : "Found Texture_Map under smBall"
'INFO : "Found Texture_Map under lgBall"
'
'INFO : "Found Superciliousness under smBall"
'INFO : "Found Superciliousness under lgBall"