##################### IMPORTER CODE ##################### # This code is called when instances of this SOP cook. node = hou.pwd() geo = node.geometry() frame = int(hou.frame()) filePath = hou.pwd().evalParm("filePath") f = open(filePath + '/parts_' + '%04d' % (frame) + '.txt', 'r') line = f.readline() line = f.readline() line = f.readline() line = f.readline() while(line != ""): sl = str.split(line) x = float(sl[1]) y = float(sl[2]) z = float(sl[3]) point = geo.createPoint() point.setPosition((x,y,z)) line = f.readline() f.close() ##################### EXPORTER CODE ##################### # This code is called when instances of this SOP cook. node = hou.pwd() geo = node.geometry() faces = geo.prims() frame = int(hou.frame()) filePath = hou.pwd().evalParm("filePath") file = open(filePath + '/mesh_' + '%04d' % (frame) + '.obj', 'w') for face in faces: vertex = face.positionAt(2.0/3.0) x = vertex[0] y = vertex[1] z = vertex[2] file.write( 'v ' + str(x) + ' ' + str(y) + ' ' + str(z) + '\r\n' ) vertex = face.positionAt(1.0/3.0) x = vertex[0] y = vertex[1] z = vertex[2] file.write( 'v ' + str(x) + ' ' + str(y) + ' ' + str(z) + '\r\n' ) vertex = face.positionAt(0.0/3.0) x = vertex[0] y = vertex[1] z = vertex[2] file.write( 'v ' + str(x) + ' ' + str(y) + ' ' + str(z) + '\r\n' ) count = 0 for f in faces: file.write( 'f ' ) file.write( str(3*count + 1) ) file.write( ' ' ) file.write( str(3*count + 2) ) file.write( ' ' ) file.write( str(3*count + 3) ) file.write( '\r\n' ) count = count + 1 file.close()