setAttribValue() slow down [solved]

   1861   2   1
User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
Hi, i made a Python Script to read vertex color information from .obj files:

input sample: “v -38.000000 0.000000 -32.000000 0.549020 0.384314 0.266667”

#hashtag added on purpose
node = hou.pwd()
geo = node.geometry()
#Cd = geo.addAttrib(hou.attribType.Point, “Cd”, (0.0, 0.0, 0.0))

input_file = open('CUsers/Linder/Desktop/World out/to2.obj')

for i, line in enumerate(input_file):
new_point = hou.Geometry.createPoint(geo)
pos = line.split()
hou.Point.setPosition(new_point, map(float, pos))
# geo.points().setAttribValue(“Cd”, map(float, pos))
input_file.close()


This script import creates 90,000 points in about 0.05 s, but when I delete the hashtag from setAttribValue() to assign the color, it takes forever.

Any solutions?
It is possible to create the point and the color at the same time?

Thanks in advance.
Edited by - Aug. 22, 2014 00:10:29
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
Have you tried this?


new_point.setAttribValue(“Cd”, map(float, pos))


The points() call creates a new array of point objects every time it's called, which is an enormous waste of time when called in a loop like this. Especially since you have the new_point value already.

Mark
User Avatar
Member
41 posts
Joined: Feb. 2014
Offline
mtucker
Have you tried this?


new_point.setAttribValue(“Cd”, map(float, pos))


The points() call creates a new array of point objects every time it's called, which is an enormous waste of time when called in a loop like this. Especially since you have the new_point value already.

Mark

thank you so much, seriously, thank you so much
  • Quick Links