Re: Diving into python, some questions...

Date : Thu, 24 Aug 2006 08:11:56 -0400
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: Diving into python, some questions...
i thought getting into python would be easier or at least more fun... I am
not having much fun at the moment, maybe someone can share some insight.

That will change. In Python it can only be fun.



I have read about the collection types in python. lists, dictionaries,
tuples great stuff. but in XSI i have noticed that sometimes i can use [ ]
brackets when indexing an XSICollection and I can also use ( ) as normal. i
shouldn't do that right?

As Aloys, I'd stick with the XSI SDK convention. I remember someone (I think it's Guy) had to modify a whole bunch of scripts not so long ago for this very reason. A new version was released and somehow the [] trick wasn't working anymore in place of collection lookup calls.



Does the extra collection types in python interfere with XSICollections?

Not that I'm aware of. I have never tried to put a list-dictionary-tuple into an XSICollection, but the other way around works perfectly. That is, you can put XSICollections into a list-dictionary-tuple (although you can't use them as dictionary keys). I do that a lot for my XML read-write tools. Oh and btw, you can put any COM object (see below) in the Python native sequence types.



When a method returns an XSICollection is python interpreting that some
other way, maybe into its native collection types?

It's interpreting it as a COM object of "XSICollection" type. With VB and JS the "COM object" part is irrelevant, but with Python it is exposed at all times. Anyone correct me if i'm wrong, but any *object* (ie class instance) provided by the XSI scripting API is a COM object.



Btw, here is a summary of how to setup Python for XSI. I don't know
how much useful it will be for you though, as you are already up and
running:
http://www.bernardlebel.com/wiki/index.php/3D:XSI_scripts/plugins:Bernard%27s_Tools_Installation_Guide#Python
The relevant part are "How do I hack the pywin32 module?" and "How do
I make "import" work?"
This is intended for people who want to use my larger tools, but it's
useful for those new to Python as well.
Also check the Programming FAQ on XSI Base, lots of tips with Python.
And don't forget xsi-blog.com!


Cheers Bernard --- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.