derMars

derMars

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Import data to array with python June 14, 2016, 4:35 a.m.

Hi,

one mistake was, that my value was a string when trying to setAttribValue. Now it should be fine, and it still works fine if the value is not an array. Guess I have to find another way …

Import data to array with python June 13, 2016, 10:17 a.m.

Hello,

I am importing some values from an external txt file with python on geometry level. Now I am having issues to write the imported data as attribute (array) to use it with wrangle nodes later on. If I use point.setAttribValue() with a single float or integer value everything seems fine, but arrays won't work and I get an error (wrong attribute/data type).



The txt-File I'm importing looks like:
0;2
2;1;3
8;4;9
1;3
4;8;9
8;1
2;5;8;9
1
1;2;3;4;5;6;7

And my python operator like this:
geo = hou.pwd().geometry()
conpoints = geo.addAttrib(hou.attribType.Point, "conpoints", 0)
filePath = hou.pwd().evalParm("filePath")
    
for line in open(filePath, 'r').readlines():
    point = geo.createPoint()
    val = line.strip().split(';')
    point.setAttribValue(conpoints, val)

Is it possible to save arrays as point attributes with python?

Thanks!
mars

SOP Solver Point Attribute March 7, 2015, 12:16 p.m.

ops: Well, that's embarrassing. I thought I checked everything twice and got unsure. Thanks for your help; it works now.