Envelope.SetDeformerWeights2

v10.5 (2012)

Description

Sets the envelope weights for a given deformer without normalizing the weights. Use the Envelope.SetDeformerWeights method if you want to normalize weights.

The deformer weights need to be passed in the cluster index order not in the geometry index order. To retrieve the cluster index corresponding to a given geometry index you can use Envelope.Elements in conjunction with ClusterElementCollection.FindIndex.

Scripting Syntax

 ```Envelope.SetDeformerWeights2( Deformer, [Weights] ); ```

Parameters

Parameter Type Description
Deformer X3DObject or expression deformer object
Weights Array of Doubles Array of weights, one for each point influenced by the Envelope

Examples

Python Example

 ```# This example shows how to set vertex envelope weights # on a deformer without normalizing the weights xsiApp = Application # Create the scene made of a cube and 3 nulls xsiApp.NewScene( None, False ) root = xsiApp.ActiveProject.ActiveScene.Root grid = root.AddGeometry( "cube", "MeshSurface" ) n = root.AddNull() n1 = root.AddNull() n2 = root.AddNull() # Move the nulls xsiApp.Translate( n, 1, 0, 1 ) xsiApp.Translate( n1, 0, 0, 1 ) xsiApp.Translate( n2, 0, 0, 0 ) # Create a deformer list made of the 3 nulls deformers = XSIFactory.CreateObject( "XSI.Collection" ) deformers.Add( n ) deformers.Add( n1 ) deformers.Add( n2 ) # Create an Envelope Weight on the grid with the 3 nulls env = grid.ApplyEnvelope( deformers ) # Output the current values of the Envelope Weight xsiApp.LogMessage( "Envelope Weights before user edit" ) allWeights = env.GetWeights2( None ) i = 0 for vertexWeights in allWeights: sum = 0 for singleWeight in vertexWeights: sum += singleWeight xsiApp.LogMessage( "Vertex " + str( i ) + ": " + str( "Deformer 0: %4.1f, " % vertexWeights[ 0 ] ) + str( "Deformer 1: %4.1f, " % vertexWeights[ 1 ] ) + str( "Deformer 2: %4.1f, " % vertexWeights[ 2 ] ) + str( "Vertex Weight Sum: %5.1f" % sum ) ) i += 1 xsiApp.LogMessage( "" ) # Set new vertex envelope weights for the first deformer env.SetDeformerWeights2( n, [10,10,10,10,10,10,10,10] ) # Output the new values of the Envelope Weight xsiApp.LogMessage( "Envelope Weights after user edit" ) allWeights = env.GetWeights2( None ) i = 0 for vertexWeights in allWeights: sum = 0 for singleWeight in vertexWeights: sum += singleWeight xsiApp.LogMessage( "Vertex " + str( i ) + ": " + str( "Deformer 0: %4.1f, " % vertexWeights[ 0 ] ) + str( "Deformer 1: %4.1f, " % vertexWeights[ 1 ] ) + str( "Deformer 2: %4.1f, " % vertexWeights[ 2 ] ) + str( "Vertex Weight Sum: %5.1f" % sum ) ) i += 1 #----------------------------------------- # Output of this example is the following: #----------------------------------------- # INFO : Envelope Weights before user edit # INFO : Vertex 0: Deformer 0: 0.0, Deformer 1: 41.5, Deformer 2: 58.5, Vertex Weight Sum: 100.0 # INFO : Vertex 1: Deformer 0: 48.0, Deformer 1: 0.0, Deformer 2: 52.0, Vertex Weight Sum: 100.0 # INFO : Vertex 2: Deformer 0: 0.0, Deformer 1: 41.5, Deformer 2: 58.5, Vertex Weight Sum: 100.0 # INFO : Vertex 3: Deformer 0: 48.0, Deformer 1: 0.0, Deformer 2: 52.0, Vertex Weight Sum: 100.0 # INFO : Vertex 4: Deformer 0: 0.0, Deformer 1: 57.8, Deformer 2: 42.2, Vertex Weight Sum: 100.0 # INFO : Vertex 5: Deformer 0: 59.3, Deformer 1: 40.7, Deformer 2: 0.0, Vertex Weight Sum: 100.0 # INFO : Vertex 6: Deformer 0: 0.0, Deformer 1: 57.8, Deformer 2: 42.2, Vertex Weight Sum: 100.0 # INFO : Vertex 7: Deformer 0: 59.3, Deformer 1: 40.7, Deformer 2: 0.0, Vertex Weight Sum: 100.0 # INFO : # INFO : Envelope Weights after user edit # INFO : Vertex 0: Deformer 0: 10.0, Deformer 1: 37.3, Deformer 2: 52.7, Vertex Weight Sum: 100.0 # INFO : Vertex 1: Deformer 0: 10.0, Deformer 1: 0.0, Deformer 2: 52.0, Vertex Weight Sum: 62.0 # INFO : Vertex 2: Deformer 0: 10.0, Deformer 1: 37.3, Deformer 2: 52.7, Vertex Weight Sum: 100.0 # INFO : Vertex 3: Deformer 0: 10.0, Deformer 1: 0.0, Deformer 2: 52.0, Vertex Weight Sum: 62.0 # INFO : Vertex 4: Deformer 0: 10.0, Deformer 1: 52.0, Deformer 2: 38.0, Vertex Weight Sum: 100.0 # INFO : Vertex 5: Deformer 0: 10.0, Deformer 1: 40.7, Deformer 2: 0.0, Vertex Weight Sum: 50.7 # INFO : Vertex 6: Deformer 0: 10.0, Deformer 1: 52.0, Deformer 2: 38.0, Vertex Weight Sum: 100.0 # INFO : Vertex 7: Deformer 0: 10.0, Deformer 1: 40.7, Deformer 2: 0.0, Vertex Weight Sum: 50.7 ```