ICEAttribute.DataArray2D

説明

この属性によって定義された 2D データを含む 2D Array オブジェクトを設定または戻します。戻された配列について、ICEAttribute.IsConstant が true の場合、その配列には定数値を含んだ項目が 1 つだけあります。属性の構造タイプが配列以外の場合は、空の配列を戻します。

C#構文

// get accessor

Object rtn = ICEAttribute.DataArray2D;

// set accessor

ICEAttribute.DataArray2D = Object;

1. Python の例

#

# This example demonstrates how to extract the 2D Array data from an envelope weight property

#

from win32com.client import constants

xsi = Application

cone = xsi.CreatePrim("Cone", "MeshSurface", "", "")

xsi.Create2DSkeleton(2.90328069018741, 3.34950957748764, -0.334950957748767, 4.73127223586102, -8.03882298597018E-02, 8.03882298597003E-03, -5.71059313749964, 0, 0, 4, "", "")

xsi.AppendBone("eff", 3.70974754857278, -3.02795665804866, 0.302795665804869, "")

xsi.ApplyFlexEnv( "cone;bone,bone1,eff", -1 )

xsi.SelectObj("cone.polymsh.cls.EnvelopWeightCls.Envelope_Weights", "", "")

attrs = xsi.Selection(0).ICEAttributes;

# Make sure the envelope weight data is generated

cone.ActivePrimitive2.GetGeometry( 0 )

for attr in attrs:

	if attr.StructureType != constants.siICENodeStructureArray:

		continue

	xsi.LogMessage( "*******************************************************************" )

	xsi.LogMessage( "Name: " + attr.Name )

	xsi.LogMessage( "DataType: " + str(attr.DataType) )

	xsi.LogMessage( "StructType: " + str(attr.StructureType) )

	xsi.LogMessage( "ContextType: " + str(attr.ContextType) )

	xsi.LogMessage( "IsDefined: " + str(attr.IsDefined) )	

	xsi.LogMessage( "IsConstant: " + str(attr.IsConstant) )

	xsi.LogMessage( "Readonly: " + str(attr.IsReadonly) )

	xsi.LogMessage( "AttributeCategory: " + str(attr.AttributeCategory) )

	xsi.LogMessage( "Element count: " + str(attr.ElementCount) )

	if attr.IsDefined == 0:

		continue

	dataType = attr.DataType

	data2D = attr.DataArray2D

	for data in data2D:

		for elem in data:

			if dataType == constants.siICENodeDataFloat:

				xsi.LogMessage( "float: " + str(elem) )

			elif dataType == constants.siICENodeDataLong: 

				xsi.LogMessage( "long: " + str(elem) )

			elif dataType == constants.siICENodeDataBool: 

				xsi.LogMessage( "bool: " + str(elem) )

			elif dataType == constants.siICENodeDataVector3: 

				xsi.LogMessage( "Vector3: " + str(elem.X) + ":" + str(elem.Y) + ":" + str(elem.Z) )

			elif dataType == constants.siICENodeDataQuaternion: 

				xsi.LogMessage( "Quaternion: " + str(elem.W) + ":" + str(elem.X) + ":" + str(elem.Y) + ":" + str(elem.Z) )

			elif dataType == constants.siICENodeDataRotation: 

				xsi.LogMessage( "Rotation: " + str(elem.RotX) + ":" + str(elem.RotY) + ":" + str(elem.RotZ) )

			elif dataType == constants.siICENodeDataMatrix33: 

				xsi.LogMessage( "Matrix33:" );

				xsi.LogMessage( str(elem.Value(0,0)) + ":" + str(elem.Value(0,1)) + ":" + str(elem.Value(0,2)) )

				xsi.LogMessage( str(elem.Value(1,0)) + ":" + str(elem.Value(1,1)) + ":" + str(elem.Value(1,2)) )

				xsi.LogMessage( str(elem.Value(2,0)) + ":" + str(elem.Value(2,1)) + ":" + str(elem.Value(2,2)) )

			elif dataType == constants.siICENodeDataMatrix44: 

				xsi.LogMessage( "Matrix44:" );

				xsi.LogMessage( str(elem.Value(0,0)) + ":" + str(elem.Value(0,1)) + ":" + str(elem.Value(0,2)) + ":" + str(elem.Value(0,3)))

				xsi.LogMessage( str(elem.Value(1,0)) + ":" + str(elem.Value(1,1)) + ":" + str(elem.Value(1,2)) + ":" + str(elem.Value(1,3)))

				xsi.LogMessage( str(elem.Value(2,0)) + ":" + str(elem.Value(2,1)) + ":" + str(elem.Value(2,2)) + ":" + str(elem.Value(2,3)))

				xsi.LogMessage( str(elem.Value(3,0)) + ":" + str(elem.Value(3,1)) + ":" + str(elem.Value(3,2)) + ":" + str(elem.Value(3,3)))

			elif dataType == constants.siICENodeDataColor4: 

				xsi.LogMessage( "Color:" );

				xsi.LogMessage( str(elem.Red) + ":" + str(elem.Green) + ":" + str(elem.Blue) + ":" + str(elem.Alpha) )

			elif dataType == constants.siICENodeDataString: 

				xsi.LogMessage( "String: " + elem );

# Expected results:

# INFO : *******************************************************************

# INFO : Name: EnvelopeWeightsPerDeformer

# INFO : DataType: 4

# INFO : StructType: 2

# INFO : ContextType: 2

# INFO : IsDefined: True

# INFO : IsConstant: False

# INFO : Readonly: False

# INFO : AttributeCategory: 1

# INFO : Element count: 26

# INFO : float: (0.0, 0.0, 0.0)

# INFO : float: (0.0, 0.0, 0.0)

# INFO : float: (0.0, 0.0, 0.0)

# INFO : float: (0.0, 0.0, 0.0)

# INFO : float: (0.0, 0.0, 0.0)

# etc.

2. Python の例

#

# This example shows how to create and set 2D array attributes

#

from win32com.client import constants

xsi = Application

xsi.NewScene("", "false")

xsi.CreatePrim("Cone", "MeshSurface", "", "")

attr = xsi.Selection(0).ActivePrimitive2.Geometry.AddICEAttribute("testattrib", constants.siICENodeDataString, constants.siICENodeStructureArray, constants.siICENodeContextSingleton );

c1 = "text"

c2 = "text2"

attr.DataArray2D = [[c1,c2,"FilePath"]]

dataType = attr.DataType;

xsi.LogMessage( "*******************************************************************" )

xsi.LogMessage( "Name: " + attr.Name )

xsi.LogMessage( "ICEString:" );

for a in attr.DataArray2D:

	xsi.LogMessage( a )

# Expected results:

# INFO : *******************************************************************

# INFO : Name: testattrib

# INFO : ICEString:

# INFO : (u'text', u'text2', u'FilePath')

関連項目

ICEAttribute.DataArray ICEAttribute.GetDataArrayChunk ICEAttribute.GetDataArray2DChunk