Just after a glance, but are you sure you want to do:
shots = ' '.join(shots)

That will create a long string out of the list of shots you grabbed from
your DB, which unless you're printing that string to the console somewhere,
you almost certainly don't want.
--alex

On Sep 28, 2011, at 7:46 AM, "tntdyna" <[email protected]>
wrote:

Hi All,

I'm getting a funny bug in some of my python coding that I hope someone
might be able to help me out with.

The background: I have a custom start up panel that links into the write
node, with the data being pulled from a SQL database through an ODBC
connection. It provides the artist with a drop down of projects that they
can select, and then gives them a list of the shots that they are working on
for that project. This then sets several knobs on a custom tab on the write
node which are, project, shot and resolution. The part I'm having trouble
with is the resolution…

When the shot is chosen two arrays are created, one containing the shot
names and the other the corresponding resolutions at the same index. To get
the correct resolution I do a comparison of the shot to the items in the
list to get its index, and then use that to pull the resolution. The issue
is that the index that I get from the comparison is a factor of 4. For
example, if I want to get the 1st or 2nd index (e.g. resolution[0]) of the
resolution list I have to divide by 4. If I want to access only the 1st 4
items in the list then I divide by 8, for the 1st 6 items then 12. e.g. if I
have a list of 10 items, if I divide the index by 8 I will only be able to
get values for the 1st 4 items, the other 6 will claim 'list index out of
range'. I've tested the code in a python shell, and in the Nuke script
editor itself, and they both produce the correct output, it only seems to be
when Nuke is starting up that the multiplication is occurring.

I'm hoping that someone can tell me whether its my code, or Nuke that is
causing the problem. I don't think its my code, as explained above it works
in the python shell. Below is the relevant code:

*Code:*  production = 'some_project'
shots = []
res_list = []
for shot in cursor.execute("SELECT name, shot, resolution, project FROM
table WHERE project = '"+production+"' ORDER BY production"):
   s = str(shot)
   ss = eval(s)
   shots.append(ss[1])
   res_list.append(ss[2])

shotarray = string.join(shots, ',')
shots.append('None')
res_list.append('')
shots = ' '.join(shots)

r = nuke.Panel("SenateVFX Shot System")
r.addEnumerationPulldown("Please choose a Shot:", shots)
if r.show():
   shot = r.value("Please choose a Shot:")
index = shots.index(shot)
real_index = pos / 8

The result of the above would be: shots = [shot1, shot2, shot3, …], res_list
= [1024x576, 1280x720, 1920x1080, …], index = 16, real_index = 2.

Thanks for any help.

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to