Mon, Dec 23, 2:07 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Dumb question of the day list unpacking


grichter ( ) posted Thu, 03 February 2011 at 12:57 AM · edited Mon, 23 December 2024 at 1:53 AM

Semi rookie

But

InColorValue = [0.607843, 0.686275, 0.811765]

and print InColorValue returns

0.607843
0.686275
0.811765

to unpack the list I have tried several methods I have found on the net which lead me to believe this should work.

r1, g1, b1 = InColorValue

But based on all the various ways I have found on the net about unpacking tupols or lists I keep getting the following TypeError: unpack non-sequence

So I am doing something very basic wrong. What is it?

I want to feed the values into a material node using a .SetColor(r1,g1,b1)

Thanks in advance for any tips or suggestions

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"


markschum ( ) posted Thu, 03 February 2011 at 1:07 PM

use an index

print  len(incolorvalue)

r = incolorvalue[1]

g = incolorvalue[2]

b = incolorvalue[3]

I dont remember offhand if the index starts at 1 or 0 but should be easy to check

www.python.org and get the manuals


adp001 ( ) posted Thu, 03 February 2011 at 1:50 PM

Because Poser Python is somewhat outdated (even with P8), try this:

<pre style="font-family:'courier new', courier;">

ar=[1.234, 2.345, 3.456] >>> ar [1.234, 2.3450000000000002, 3.456]

a,b,c=tuple(ar) >>> a 1.234 >>> b 2.3450000000000002 >>> c 3.456




markschum ( ) posted Thu, 03 February 2011 at 4:02 PM

thats a nicer method , noted , thanks .


grichter ( ) posted Sun, 06 February 2011 at 11:51 AM

Found my problem using what I assumed would work.  Based on conditions I import various other scripts and had a typo, that for the life of me I couldn't see. So the original problem is mute. But you examples make things even easier when I want to pick one out of the list or tuple.

Thanks a million

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.