Import data to array with python

   3363   1   0
User Avatar
Member
8 posts
Joined: Jan. 2015
Offline
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
Edited by derMars - June 13, 2016 10:20:36
User Avatar
Member
8 posts
Joined: Jan. 2015
Offline
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 …

Edited by derMars - June 14, 2016 04:38:06
  • Quick Links