burakumincgi Posted November 22, 2018 Share Posted November 22, 2018 hi, I'd like to start by saying that I'm only a couple of days into python and I'm aware the code might not be the most beautiful, but it seems to work, for the most part. I am simply reading a txt file with RGB value in each line, then I'm assigning to a ramp as many ramp points as there are lines with a sorted random position. so far so good, everything works.. the problem is that the script works only when I manually write each color, they definitely get assigned to the ramp, I can see it works because the position of the flags changes every time I execute the script. (image_A) but I get an error when I try to assign them with a variable that reads from the file, and the whole script fails, the position of the flags never changes when I get the error. (image_B) the weird thing is that I know that the numbers stored in my variable are correct because I can print them on the shell regardless if the script fails or not. hopefully there is some one that can help, this is the script that works: import hou from random import random with open('C:/tmp/gradient.txt', 'r+') as f: gradientValues = f.read() gradientValues = gradientValues.replace("\n", ", "); rampPoints = len(open('C:/tmp/gradient.txt').readlines( )) tmpList = [] for _ in range(rampPoints): value = random() tmpList.append(value) pointPosition = sorted(tmpList) print (rampPoints) print (pointPosition) print (gradientValues) node = hou.node('/img/img1/vopcop2gen5') ramp_parm = node.parm('/img/img1/vopcop2gen5/ramp1') ramp = hou.Ramp(([hou.rampBasis.Linear] * rampPoints), pointPosition, ((0.0,0.456,0.789), (0.111,0.0,0.333), (0.0,0.555,0.666))) ramp_parm.set(ramp) f.close() this is the one that fails: ramp = hou.Ramp(([hou.rampBasis.Linear] * rampPoints), pointPosition, (gradientValues)) and this is the error: The attempted operation failed. Traceback (most recent call last): File "hou.session", line 21, in <module> File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.352/houdini/python2.7libs\hou.py", line 49159, in __init__ this = _hou.new_Ramp(*args) TypeError: in method 'new_Ramp', argument 3 of type 'std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > const &' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.