Forum: Poser Python Scripting


Subject: Does not find light sets?

Amadan opened this issue on Apr 16, 2009 · 5 posts


Amadan posted Thu, 16 April 2009 at 12:59 PM

My Poser gui selects multiple light sets, so as to perform a batch render of a scene using each light set selected.

The problem is, while the light sets seem to be selected properly, when I render, Poser won't find them using the given paths.

Here is the relevant code:

   
""" callback for the chooseb button. Selects
lightsets to render. """
<br></br>
    <span style="color:rgb(0,0,255);">def</span>
<strong>addLights</strong>(self):<br></br>
        self.lightsets =
tkFileDialog.askopenfilenames(**self.file_opts)<br></br>
        <span style="color:rgb(0,0,255);">for</span> i <span style="color:rgb(0,0,255);">in</span> self.lightsets:<br></br>
           
self.lightlist.insert(END, i)

(self.lightlist is a Listbox.)

This works fine -- I get the lightsets selected, with their full path names.

Then I press the render button, which does this:

   
""" render all selected lightsets
"""
<br></br>
    <span style="color:rgb(0,0,255);">def</span>
<strong>renderLights</strong>(self):<br></br>
        <span style="color:rgb(0,0,255);">if</span> self.outdir == 0:<br></br>
           
poser.DialogSimple.MessageBox(<span style="color:rgb(51,153,102);">"You must choose an output
directory!"</span>)<br></br>
        <span style="color:rgb(0,0,255);">else</span>:<br></br>
           scene =
poser.Scene()<br></br>
           <span style="color:rgb(0,0,255);">for</span> lights <span style="color:rgb(0,0,255);">in</span> self.lightsets:<br></br>
          
    <span style="color:rgb(0,0,255);">if</span>
os.path.exists(lights):<br></br>
           
      scene.LoadLibraryLight(lights)<br></br>
           
      scene.Render()<br></br>

(Code for saving files to the output directory omitted.)

Notice that I added a check that the lightset file being loaded actually exists. But this doesn't work -- the file does exist, yet when it comes to LoadLibraryLight, Poser pops up a dialog asking me to locate the file in question. Note that it pops up the dialog with the directory in which the file is located being the default location. And once I select a file, it does find all the others correctly -- and will do so again without any warnings if I hit the render button again. But it can't seem to find the file correctly the first time.