How to set parmTuple with list in python ?

   3811   6   1
User Avatar
Member
11 posts
Joined: 11月 2013
Offline
Hello, I try :

a = hou.parmTuple(path_diffuse + ‘/diff_color’)
a.set((0.8, 0.8, 0.8))

ok It works.

Liste =
a = hou.parmTuple(path_diffuse + ‘/diff_color’)
a.set(Liste)

It don't works. I have tried different things, but I always gets

File “CPROGRA~1/Side Effects Software/Houdini 15.0.329/houdini/python2.7libs\hou.py”, line 25122, in set
return _hou.ParmTuple_set(*args)
InvalidSize: Invalid size.

Thanks for your help….
User Avatar
Member
2629 posts
Joined: 6月 2008
Offline
You still need the inner parenthesis, right?


a.set((Liste))

or

a.set((Liste,Liste,Liste))


Your list should not be a string either just use float numbers.

Liste =
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
1922 posts
Joined: 11月 2006
Online
The issue is that the list you are trying to set is really a single element list that contains a string. Remove those quotes and it will work.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
11 posts
Joined: 11月 2013
Offline
Thanks for your replies.

Then, create my list manually without quote ok it works now.
But I want to do the same in a way procedural from a text file.

source_file :
0.8, 0.8, 0.8
0.8, 0.8, 0.8
0.9294118, 0.09019608, 0
0.8, 0.8, 0.8
fichier = open(source_file , ‘r’)
for ligne in fichier:
line = ligne.strip()
Liste.append(line)
fichier.close()
a = hou.parmTuple(path_diffuse + ‘/diff_color’)
a.set(Liste)
>>> print Liste

>>>

I cannot edit my list by removing the quotes (in a way procedural) while keeping tuples for the changes in my hou.parmTuple()… :?
User Avatar
Member
1922 posts
Joined: 11月 2006
Online
In that case you can simply evaluate the string values to turn them into valid Python numerical types and set those. If you run something like eval('0.8, 0.8, 0.8') that should give you a 3 element tuple of float values which you can use to set.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
11 posts
Joined: 11月 2013
Offline
Thanks for your help. It works…

I can retrieve each tuple of my list…


>>>Liste =
>>> a = hou.parmTuple(path_diffuse + ‘/diff_color’)
>>> a.set(eval(Liste))
>>> a.set(eval(Liste))
>>> a.set(eval(Liste))
>>> a.set(eval(Liste))
User Avatar
Member
1 posts
Joined: 1月 2016
Offline
I was also facing the same problem but this post helped me out at some point. thanku sir ..
Virtuoso [virtuoso.co.in]
  • Quick Links