2011년 11월 4일 금요일

Custom Particle File

import hou
source = hou.node('/obj/geo1/popnet1')
path_ = hou.expandString("$HIP")
def writeParticlesInCustomFormat(popnet, file_name):
    """Write the particle data in the geometry geometry to a custom file
       format."""
    geo = popnet.geometry()
    f = file(file_name, "w")
    # Write out the number of particle attributes, followed by the particle
    # attribute information.
    f.write("%d attributes:\n" % len(geo.pointAttribs()))
    for attrib in geo.pointAttribs():
        f.write("%s %s %d\n" %
            (attrib.name(), attrib.dataType(), attrib.size()))
    f.write("\n")
    # Write the number of particles, followed by the particle attribute values.
    f.write("%d points:\n" % len(geo.points()))
    for point in geo.points():
        for attrib in geo.pointAttribs():
            f.write("%s = %s\n" % (attrib.name(), point.attribValue(attrib)))
        f.write("\n")
    f.close()
writeParticlesInCustomFormat(source,path_+"/"+"test.csv")

댓글 없음:

댓글 쓰기