Re: Python for loops on objects
| Date : Sun, 15 Apr 2007 07:20:18 +0100 |
| To : XSI(at)Softimage.COM |
| From : Julian Johnson <julian(at)exch.demon.co.uk> |
| Subject : Re: Python for loops on objects |
import win32com c = win32com.client.constants xsi = Application
oClusters = xsi.Selection(0).ActivePrimitive.Geometry.Clusters
for oCls in oClusters:
if ( oCls.type == c.siSampledPointCluster ):
oCluster = oCls
break#just to check the element array is really there for x in oCluster.LocalProperties: print x print ClassName(x) print x.Elements.Array
#the acid test with square brackets oUVspace = oCluster.LocalProperties[0]
aElements = oUVspace.Elements.Array
print ClassName(oUVspace)
print aElements
Julian
.........................................................................................
Men-From-Mars, Ealing, London
Scripts: http://www.exch.demon.co.uk/jj_xsiscripts.htm
kim aldis wrote:
Hmm, works here too. Digging deeper.
-----Original Message----- From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Francois Lord Sent: 13 April 2007 19:33 To: XSI(at)Softimage.COM Subject: Re: Python for loops on objects
Yes. I have Active Python 2.4 with the hack and your script (and Kim's) works fine in 6.01.
Bernard Lebel wrote:
youIndeed. Before 6.0, that used to be a typical dispatch problem that required the pywin32 hack or forced dynamic dispatching to work.
This works perfectly for me in 5.11:
import win32com c = win32com.client.constants xsi = Application
oClusters = xsi.selection(0).activeprimitive.geometry.clusters
for oCls in oClusters: if ( oCls.type == c.siSampledPointCluster ): oCluster = oCls break
t = oCls.Elements xsi.logmessage( t.count ) xsi.logmessage( xsi.classname( t ) ) xsi.logmessage( str( t.array ) )
I wonder if hacking pywin32, even if used in 6.0, would fix this.
Cheers Bernard
On 4/13/07, Kim Aldis <XSI(at)kim-aldis.co.uk> wrote:
It's misleading. Putting a logmessage of oCls in the loop prints a
sensible
name. it's only when you try and access any properties that it kicks
youout. If you haven't checked it thoroughly you may want to.
-----Original Message----- From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Bernard Lebel Sent: 13 April 2007 15:16 To: XSI(at)Softimage.COM Subject: Re: Python for loops on objects
No problem at all here. Note that I'm using XSI 5.11, so my pywin32 is hacked......
Cheers Bernard
On 4/13/07, Kim Aldis <XSI(at)kim-aldis.co.uk> wrote:
Has anyone noticed this seems to give you an object in oCls but
text incan'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
inbody:
---unsubscribe xsi
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text
---body:
unsubscribe xsi
--- 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
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
--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi
- Follow-Ups:
- Re: Python for loops on objects
- From: Julian Johnson <julian(at)exch.demon.co.uk>
- Re: Python for loops on objects
- References:
- Python for loops on objects
- From: "Kim Aldis" <XSI(at)kim-aldis.co.uk>
- Re: Python for loops on objects
- From: "Bernard Lebel" <3dbernard(at)gmail.com>
- RE: Python for loops on objects
- From: "Kim Aldis" <XSI(at)kim-aldis.co.uk>
- Re: Python for loops on objects
- From: "Bernard Lebel" <3dbernard(at)gmail.com>
- Re: Python for loops on objects
- From: Francois Lord <francoislord(at)gmail.com>
- RE: Python for loops on objects
- From: "kim aldis" <kim.aldis(at)gmail.com>
- Python for loops on objects
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: Re: Python for loops on objects
- Next by Date: Re: Python for loops on objects
- Previous by Thread: Re: Python for loops on objects
- Next by Thread: Re: Python for loops on objects
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |