Re: Diving into python, some questions...

Date : Thu, 24 Aug 2006 16:34:01 +0930
To : XSI(at)Softimage.COM
From : Nick <nick.petit(at)gmail.com>
Subject : Re: Diving into python, some questions...
Aloys beat me to it... :)

On 8/24/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.