• Kenny Lammers

Intro to Python - Houdini 18 - Writing parameter data to text files


Learning to write data out to a file is very important when it comes to developing pipelines for games or cg in general. So lets start with something simple, writing data out to a text file. This is probably the most basic way to write out data. Later on in the series we will dive into more advanced and more efficient ways of writing data, but lets get our feet wet with the basics first.

Python Code:


def export_parms(kwargs):
    
    #get the parent node from the kwargs dictionary
    parent = kwargs['node']
    
    #Get the parms we wnt to export
    uniformscale = str(parent.parm('scale2').evalAsFloat())
    sizex = str(parent.parm('sizex').evalAsFloat())
    sizey = str(parent.parm('sizey').evalAsFloat())
    sizez = str(parent.parm('sizez').evalAsFloat())
    
    #Create an Array of the parms for exporting
    lines = [uniformscale,
    sizex,
    sizey,
    sizez]
    
    #Write the file to a text file
    path = 'some path to a location on your computer'
    f = open(path, 'w')
    f.writelines(lines)
    f.close()

Enjoy the video!


Kenny

indie-Pixel

35 views0 comments

© 2018 by Indie-Pixel

  • YouTube - White Circle
  • Facebook - White Circle
  • Twitter - White Circle