Hython animation

From DreamsteepWiki

Jump to: navigation, search

QUEREY CURRENT FRAME


time = hou.frame()


SET CURRENT FRAME

hou.setFrame(23)


STEP THROUGH FRAMES


start =  20
end   =  40

for a in range(start,end):
  hou.setFrame(a)
  FRAM = hou.frame()
  print 'FRAME IS '+str( FRAM )


#############################################
def export_cvs_over_time (popnet):

   geo = popnet.geometry()

   for point in geo.points():
      for attrib in geo.pointAttribs():
         print("%s = %s\n" % (attrib.name(), point.attribValue(attrib)))
         #print point.attribValue(attrib)


################################################
#writeFireworks()
start =  20
end   =  25

for a in range(start,end):
  hou.setFrame(a)
  FRAM = hou.frame()
  print 'FRAME IS '+str( FRAM )
  #writeFireworks( ('C:/fire_'+str(a)+'.txt') )
  export_cvs_over_time( hou.node("/obj/aa/popnet1") )


MODIFIED HOM COOKBOOK EXAMPLE PARTICLE COOKER OVER TIME

import hou

def writeParticlesAsGeo(popnet, file_name):
   popnet.geometry().saveToFile(file_name)
   
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()

def writeFireworks(filename):
      writeParticlesInCustomFormat(hou.node("/obj/aa/popnet1"), filename)
      
#writeFireworks()
start =  20
end   =  25

for a in range(start,end):
  hou.setFrame(a)
  FRAM = hou.frame()
  print 'FRAME IS '+str( FRAM )
  writeFireworks( ('C:/fire_'+str(a)+'.txt') )
Personal tools