Here's another example from the doc in case you missed it

win32com.client import constants
xsi = Application
xsi.CreatePrim("Sphere", "MeshSurface", "", "")
attrs = xsi.Selection(0).ActivePrimitive.Geometry.ICEAttributes
for attr in attrs:
        if attr.StructureType != constants.siICENodeStructureSingle:
               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
        # Compute the chunk vector to access the data
        nChunkCount = 4
        nChunk = attr.ElementCount / nChunkCount
        nLastChunk = attr.ElementCount % nChunkCount
        chunks = []
        for i in range(nChunkCount):
               chunks.append( nChunk )
        chunks.append( nLastChunk )
        nOffset = 0
        dataType = attr.DataType
        for i in range(len(chunks)):
               nChunk = chunks[i]
               if nChunk == 0:
                       continue;
               xsi.LogMessage( ">>>>offset: " + str(nOffset) + " chunk size: " 
+ str(nChunk) )
               data = attr.GetDataArrayChunk( nOffset, nChunk );
               nOffset += nChunk
               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 );


From: softimage-boun...@listproc.autodesk.com 
[mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Bradley Gabe
Sent: Thursday, May 03, 2012 10:31 AM
To: softimage@listproc.autodesk.com
Subject: Re: Scripting: Accessing ICEAttributes at a specific ID using 
GetDataArrayChunk?

Thanks!

This code set is a more useful example for usage than the one provided in the 
docs. I'm picking through it and modifying into what I need. If I get a working 
function I'll post it.

-B
On Thu, May 3, 2012 at 9:43 AM, Chris Chia 
<chris.c...@autodesk.com<mailto:chris.c...@autodesk.com>> wrote:
Hi Bradley,
I did a quick test on GetDataArrayChunk and it works beautifully.

si = Application
def getCloudData(obj, attName, index):
   pc = si.Dictionary.getObject(obj)
   geo = pc.ActivePrimitive.Geometry
   pp = geo.GetICEAttributeFromName(attName)
   data = pp.GetDataArrayChunk( 0, index+1 )

   j = 0
   for i in data:
       if j==index:
           si.logmessage(str(i.X) + " " + str(i.Y) + " " + str(i.Z))
           return(i.X, i.Y, i.Z)
       j = j + 1
   return(0, 0, 0)


getCloudData("pointcloud", "PointPosition", 500)


Note: This is not the best example... but just a quick guide for you.
It only works for PointPosition in the above test :D
Cheers.


Regards,
Chris Chia
QA Analyst / ICE, FaceRobot and General Specialist,
Autodesk Media and Entertainment


________________________________
From: 
softimage-boun...@listproc.autodesk.com<mailto:softimage-boun...@listproc.autodesk.com>
 
[softimage-boun...@listproc.autodesk.com<mailto:softimage-boun...@listproc.autodesk.com>]
 on behalf of Ciaran Moloney 
[moloney.cia...@gmail.com<mailto:moloney.cia...@gmail.com>]
Sent: Thursday, May 03, 2012 1:15 AM
To: softimage@listproc.autodesk.com<mailto:softimage@listproc.autodesk.com>
Subject: Re: Scripting: Accessing ICEAttributes at a specific ID using 
GetDataArrayChunk?

Hi,

accessing chunks works OK for me. What happens when you try to access the 
returned data chunk? What size chunks are you trying to get?
If you turn on verbose logging, then perhaps you'll see a message like this 
upon attempting to get the chunk:

# VERBOSE : 5403 - The data is not set on this ICEAttribute: ....

If so, then you'll need to add a display flag for that attribute (yes, that ol 
gotcha!), then it should work OK.

Ciaran


On Wed, May 2, 2012 at 4:13 PM, Bradley Gabe 
<witha...@gmail.com<mailto:witha...@gmail.com><mailto:witha...@gmail.com<mailto:witha...@gmail.com>>>
 wrote:
Is this doable? And if so, how?
I've noticed that pulling the DataArray for an ICE Attribute from my live ICE 
operator (~200K points) is taking almost a second per attribute, and I need to 
pull data from multiple attributes. I don't need the entire data set, I only 
need attribute data from a dozen or so points.

I'm not having any luck with reading the resulting chunk objects, I'm assuming 
they need to be pieced back together as a whole? The docs are sparse in this 
area.



<<attachment: winmail.dat>>

Reply via email to