Seems like COM collections are not properly exposed as list in python. Instead of using the range statement I usually use the enumerate statement to iterate over collections:
clusters = enumerate(geom.Clusters)
For i, cls in clusters:
...
Each item returned is a tuplet containing the item index + the object.
Note: using range is fine too but make sure the oClusters.Count call is done outside of the for statement because the Count property will get called at each iteration.
-mab
-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Kim Aldis
Sent: April 13, 2007 5:04 AM
To: XSI(at)Softimage.COM
Subject: Python for loops on objects
Has anyone noticed this seems to give you an object in oCls but you can't actually get any of its properties :-
for oCls in oClusters :
if ( oCls.type == constants.siSampledPointCluster ):
oCluster = oCls
break
t = oCls.Elements # ERROR!
But this works just fine:-
for i in range( oClusters.count ) :
oCls = oClusters(i)
if ( oCls.type == constants.siSampledPointCluster ):
oCluster = oCls
break
t = oCls.Elements # Works
www.kim-aldis.co.uk | kim(at)kim-aldis.co.uk
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi