Re: Diving into python, some questions...

Date : Fri, 25 Aug 2006 03:45:23 -0700
To : XSI(at)Softimage.COM
From : "Steven Caron" <carons(at)gmail.com>
Subject : Re: Diving into python, some questions...
thanks again for this

i employed these, just now and everything is working great. sept for a small speed bump with python failing on the .parameters method. fixed that though. weird thing was, the .parameters method would work for your enumelements approach, but wouldn't work for my .parameters using nestedobjects. fixed it with the gencache reset trick

On 8/23/06, Nick <nick.petit(at)gmail.com> wrote:
Pythin allows you to enumerate through lists, collections, a bit like in VB with the "for each ... in ..." which allows you to get to the individual items a lot quicker...


import xml.dom.minidom

#assign Application to a smaller variable
app = Application

#get the all the passes in the scene
oPasses = app.ActiveProject.ActiveScene
.Passes

#new XML doc
doc = xml.dom.minidom.Document()

#root element
passList = doc.createElement("PassList")
doc.appendChild(passList)

#pass elements
for oPass in oPasses:  # get each pass directly, its faster and you get to the objects you want quicker...
    passElem = doc.createElement (oPass.Name)

    passList.appendChild(passElem)
   
    #render options for each pass
    rOptElem = doc.createElement("RenderOptions")
    #rOptions = oPass.NestedObjects(3).Parameters   I'm still on 4.2 so I don't have access to "NestedObjects", so I use this instead :
    rOptions = app.EnumElements(oPass)(3).Parameters

   
    #render option's parameters and values
    for oParam in rOptions: #first syntax error
        # if rOptions.Value:  Here, you're trying to get to the value of a Collection, not an individual Parameter...
        if oParam.Value:
            parElem = doc.createElement(oParam.Name)
            rOptElem.appendChild (parElem)
            parTxt = doc.createTextNode(oParam.Value)
            parElem.appendChild(parTxt)
  ...

Hopefully that gets you on your way, I can't go on too much further as I'm missing "NestedObjects"



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.