v3.5
Renames a property and ensures that all references to the property are maintained. For example, while renaming a UV property, the command updates every reference to the property in every shader, rendermap, texturemap and material of the object, so that the reference still points to the same property.
RenamePropAndRebind( [Properties], NewName, [UpdateRefs], [UpdateWildcards] ); |
Parameter | Type | Description |
---|---|---|
Properties | Property |
Property to rename Default Value: Current selection |
NewName | String |
New name for the property Default Value: If not specified, a new name is automatically created for this property. |
UpdateRefs | Boolean |
True to update references to the property in shaders, materials, rendermaps etc. Default Value: true |
UpdateWildcards | Boolean |
True to update references containing wildcards (e.g. uvprop*) Default Value: false |
'------------------------------------------------------------------------------- ' ' 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" |