Howdy Guys! In this video I wanted to walk through the basics of writing to JSON files from your HDAs in Houdini. This is the next step in saving out data in a more complex format. JSON is a very popular format and python supports it natively. It also helps out when having to save out organized data, very crucial to pipelines.
JSON stands for JavaScript Object Notation and its great because the data is stored in a more structured way. Making it easier to read large amounts of data in a more object oriented way.
Enjoy the video!
Code:
def write_parms(kwargs):
import json
parent = kwargs['node']
parms = parent.parmsInFolder(['My_Folder'])
data = {}
data['parms'] = []
for parm in parms:
if parm.name() != 'export_parms'
name = parm.name()
value = str(parm.eval())
data['parms'].append({
'name' : name,
'value': value
})
with open('path to some file', 'w') as outfile:
json.dump(data, outfile, indent=4)
So Hopefully this helps you out! Let me know what cha think!
Thanks!
Kenny
Indie-Pixel
Kommentit