• Welcome to the Community Forums at HiveWire 3D! Please note that the user name you choose for our forum will be displayed to the public. Our store was closed as January 4, 2021. You can find HiveWire 3D and Lisa's Botanicals products, as well as many of our Contributing Artists, at Renderosity. This thread lists where many are now selling their products. Renderosity is generously putting products which were purchased at HiveWire 3D and are now sold at their store into customer accounts by gifting them. This is not an overnight process so please be patient, if you have already emailed them about this. If you have NOT emailed them, please see the 2nd post in this thread for instructions on what you need to do

How to copy color from one node to another (poser python)

Gadget Girl

Extraordinary
Contributing Artist
So I'm just curious if there's an easy way to copy the color value from one node (technically the node's input) to another node using python. Basically I want to copy the Diffuse_Color value from the PoserSurfaceNode to the Color value on a PhysicalSurfaceNode

I can get the color value of Diffuse_Color using this:
Code:
diffuseColorValue = ffRoot.Input(0).Value()
where ffRoot is the PoserSurfaceNode. If I print the value of diffuseColorValue it looks like this:
(1.0, 1.0, 1.0)

But if I try to simply pass that value into my superfly node like this:
Code:
sfRoot.Input(0).SetColor(diffuseColorValue)
where sfRoot is my PhysicalSurfaceNode, I get the error:
Error parsing SetColor()
Usage: SetColor(<FloatType> r, <FloatType> g, <FloatType> b)

Okay, so I get what's happening. The Value() is returning a tuple, and SetColor() wants three floats. And I do know how to take apart the tuple and pass in the float values one at a time, but I was just wondering if there is an easier way to do this. It seems like there should be, but I know Poser doesn't always have the python methods I think it should.

Figured it couldn't hurt to ask.
 

Ken1171

Esteemed
Contributing Artist
I have just gone through this when I made my last script, and was wondering if there us a "Pythonic" way do it. I couldn't find any, so I just passed the 3 params Poser wanted. Doesn't look very elegant, but...
 

phdubrov

Noteworthy
Contributing Artist
This should work and is short enough
Code:
r, g, b = ffRoot.Input(0).Value()
sfRoot.Input(0).SetColor(r, g, b)
not sure about Python2 and this
Code:
sfRoot.Input(0).SetColor(*ffRoot.Input(0).Value())
 

Ken1171

Esteemed
Contributing Artist
@phdubrov Oh yes, the unpacking way should work, though it still creates 3 variables. I was curious why it doesn't take a tuple with 3 values, forcing us to unpack it. They didn't overload the class hard enough to allow that.
 
Top