Search the Community
Showing results for tags 'numpy'.
Found 3 results
Hi How do I save out all geometry information to a python numpy .npy file. I'm dabbling with a neural network that takes in a bunch of objs and spits out its so called interpretation..... But as yet I am working with just the points and not the vertices and prim information. How could I save all this information to an array so I could then reload the array back into houdini for houdini to display prims/vertices etc...... Thanks for your help
It looks like it's possible to set point attributes all at once instead of looping through them one at a time. I was trying to do it with NumPy, but can't quite get it right. Seems to be problem with the custom attribute being an array. Given an array with the same shape,i.e., number of points x array size it looks like it should work, but doesn't. Incidentally, the NumPy array will contain data from a file. I can't tell there's a better way to pull file data straight into something like VEX, hence the NumPy array. Here's my test code: node = hou.pwd() g = node.geometry() pt0 = [1.0, 0.0, 0.0] point = g.createPoint() point.setPosition(pt0) pt_1 = [0.5, 0.5, -1.0] point_2 = g.createPoint() point_2.setPosition(pt_1) pt_2 = [1.5, -2.5, 0.0] point_3 = g.createPoint() point_3.setPosition(pt_2) g.addArrayAttrib(hou.attribType.Point, "MyFloats", hou.attribData.Float, 8) gp = g.points() # This works fine ''' gb0 = (0.5, 0.3, 0.1, 0.1, 0.6, 0.2, 0.3, 0.8) gp.setAttribValue("MyFloats", gb0) gb1 = (0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1) gp.setAttribValue("MyFloats", gb1) gb2 = (0.7, 0.6, 0.1, 0.5, 0.1, 0.2, 0.8, 0.9) gp.setAttribValue("MyFloats", gb2) ''' import numpy as np y = np.arange(24, dtype=np.float32).reshape(3,8) g.setPointFloatAttribValues("MyFloats", y) # error print g.pointFloatAttribValues("MyFloats") # error
On the SideFX forums I have added some information/videos & software on how to accelerate Python with Houdini in Windows & Linux: A custom node/plugin which speeds up execution of Python nodes in SOP-Context by a factor of up to 2 in certain conditions (e.g. Deformer, Attribute manipulation): Custom Python node for SOP context Using Numba (Python JIT-Compiler) in Houdini (Windows & Linux): How to use Numba with Houdini An optimzed/accelerated Numpy Python module (with OpenBLAS) for Houdini on Windows: Optimized Numpy python module for Houdini Hope it helps some people when using Python with Houdini. Any feedback welcome. Cheers