Someone asked me how to export vertex colors from Houdini.
So I gave it a quick go to see how rusty my houdini had become and turns out it was horrifically rusty.
Anyway without further ado … here is the script and otl.
Mind that the otl is made in the learning edition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import hou ## Button calls this function def Button(arg): ## Get our current node path that we give allong with the button currentNodePath = arg + '/VTX_FilePath' ## Get the filepath the user set. filePath = hou.parm(currentNodePath).eval() ## Check if user actually added a file path or is just being a nubcake if not filePath: print 'Please provide a filepath' return ## check for file extension if '.' not in filePath: filePath += '.vfxColor' ## Get our node node = hou.pwd() ## Get incoming geo geo = node.geometry() ## Build empty point list pointList = list() ## Run past all points for point in geo.points(): ## Get color info for each point color = str(point.floatListAttribValue( 'Cd' )) ## add it to our list pointList.append( color ) ## Create a file f = file(filePath, 'w') ## write our list of data and add a \n new line at the end of each item. f.writelines(["%s\n" %item for item in pointList]) ## Close the file f.close() ## Inform the user the save was successfull. print 'Successfull Export to %s' %filePath |