ICEAttribute.DataArray

Description

Sets or returns a 1D Array object containing the data defined by this attribute. If ICEAttribute.IsConstant is true, the array has only one item which contains the constant value. Returns an empty array if the attribute's structure type is not a singleton.

C# Syntax

// get accessor
Object rtn = ICEAttribute.DataArray;
// set accessor
ICEAttribute.DataArray = Object;

Examples

1. Python Example

#
# This example shows how to access all attribute data on a geometry.
#
from win32com.client import constants
xsi = Application
xsi.CreatePrim("Cone", "MeshSurface", "", "")
attrs = xsi.Selection(0).ActivePrimitive.Geometry.ICEAttributes;
for attr in attrs:
	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;
	data = attr.DataArray;
	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: SurfaceGeometricNormal
# INFO : DataType: 16
# INFO : StructType: 1
# INFO : ContextType: 1048576
# INFO : IsDefined: False
# INFO : IsConstant: False
# INFO : Readonly: True
# INFO : AttributeCategory: 1
# INFO : Element count: 0
# INFO : *******************************************************************
# INFO : Name: Volume
# INFO : DataType: 4
# INFO : StructType: 1
# INFO : ContextType: 1
# INFO : IsDefined: True
# INFO : IsConstant: True
# INFO : Readonly: True
# INFO : AttributeCategory: 1
# INFO : Element count: 1
# INFO : float: 3.77123618126
# etc.

2. Python Example

#
# This example shows how to add an attribute and set its data.
#
from win32com.client import constants
xsi = Application
xsi.NewScene("", "false")
xsi.CreatePrim("Cone", "MeshSurface", "", "")
#Type = Vector3, context = One element per polygon.
attr = xsi.Selection(0).ActivePrimitive.AddICEAttribute("MyVec3", constants.siICENodeDataVector3, constants.siICENodeStructureSingle, constants.siICENodeContextComponent2D );
attr.DataArray = [ XSIMath.CreateVector3( 1.0, 2.0, 3.0), XSIMath.CreateVector3( 4.0, 5.0, 6.0) ]
#Type = String, context = One element per vertex or point.
attr = xsi.Selection(0).ActivePrimitive.AddICEAttribute("MyString", constants.siICENodeDataString, constants.siICENodeStructureSingle, constants.siICENodeContextComponent0D );
c1 = "text"
c2 = "why"
attr.DataArray = [ c1, c2, "How" ]
#Type = Quaternion, context = One element per geometry. 
attr = xsi.Selection(0).ActivePrimitive.Geometry.AddICEAttribute("MyQuat", constants.siICENodeDataQuaternion, constants.siICENodeStructureSingle, constants.siICENodeContextSingleton );
q1 = XSIMath.CreateQuaternion( 1.0, 2.0, 3.0, 4.0 )
attr.DataArray = [ q1 ]
#Type = Rotation, context = One element per edge. 
attr = xsi.Selection(0).ActivePrimitive.Geometry.AddICEAttribute("MyRot", constants.siICENodeDataRotation, constants.siICENodeStructureSingle, constants.siICENodeContextComponent1D );
r1 = XSIMath.CreateRotation( XSIMath.DegreesToRadians( 70 ), XSIMath.DegreesToRadians( 40 ), XSIMath.DegreesToRadians( 45 ));
attr.DataArray = [ r1, r1, r1 ]
# Display the first values of the newly added attributes
attrs = xsi.Selection(0).ActivePrimitive.Geometry.ICEAttributes;
for attr in attrs:
	if attr.Name.find("My") == -1 :
		continue
	xsi.LogMessage( "*******************************************************************" )
	xsi.LogMessage( "Name: " + attr.Name )
	xsi.LogMessage( "Element count: " + str(attr.ElementCount) )	
	if attr.IsDefined == 0 :
		continue
	dataType = attr.DataType;
	data = attr.DataArray;
	i = 0 
	for elem in data:
		i += 1
		if i > 4 :
			continue 			
		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(round(elem.RotX)) + ":" + str(round(elem.RotY)) + ":" + str(round(elem.RotZ)) )
		elif dataType == constants.siICENodeDataString: 
			xsi.LogMessage( "String: " + elem );
# Expected results:
# INFO : *******************************************************************
# INFO : Name: MyQuat
# INFO : Element count: 1
# INFO : Quaternion: 1.0:2.0:3.0:4.0
# INFO : *******************************************************************
# INFO : Name: MyRot
# INFO : Element count: 56
# INFO : Rotation: 70.0:40.0:45.0
# INFO : Rotation: 70.0:40.0:45.0
# INFO : Rotation: 70.0:40.0:45.0
# INFO : Rotation: 0.0:0.0:0.0
# INFO : *******************************************************************
# INFO : Name: MyString
# INFO : Element count: 26
# INFO : String: text
# INFO : String: why
# INFO : String: How
# INFO : String: 
# INFO : *******************************************************************
# INFO : Name: MyVec3
# INFO : Element count: 32
# INFO : Vector3: 1.0:2.0:3.0
# INFO : Vector3: 4.0:5.0:6.0
# INFO : Vector3: 0.0:0.0:0.0
# INFO : Vector3: 0.0:0.0:0.0

See Also

ICEAttribute.DataArray2D ICEAttribute.GetDataArrayChunk ICEAttribute.GetDataArray2DChunk