Saori Yoshimoto work notes since 2018

Sunday, August 8, 2021

[Hython] Auto cache output settings : ver1.1

ver1.1

-auto set up output path on "cache file" node

-auto create geometry node in ROP

--

★★feature

-Added a function to notify the status by color

-Check the ROP network exists under /obj, add the auto-creation function. Currently, I get an error if it doesn't exist.

-If I try to recreate the File cache with the same name, it will get an error unless you also delete the Geometry node in the ROP. I will automate it.

[DONE]-Currently, null names only accept combinations of three words, so I plan to improve this to make it easier to use.

-Eventually, it will be a library

-It will be improved to determine the output path from the Variables setting.


#SET Global
cachepath = '$__CACHE/$__SCN/geo/$OS/v`padzero(2,chs("ver"))`/$OS.$FF.bgeo.sc'
cacheout_color = hou.Color((0.475,0.812,0.204))

source_node = hou.selectedNodes()[0]
source_node_out = source_node.outputs()[0]

#CREAT cache file
file_cache = source_node.parent().createNode('filecache')
file_cache.setParms({'file':cachepath})
#CREAT cache file - modify name
file_cache_n = source_node.name().split('_')
file_cache_n.pop(0)
file_cache_new = '_'.join(file_cache_n)
file_cache.setName(file_cache_new)

file_cache.setInput(0, source_node, 0)
file_cache.moveToGoodPosition()
file_cache.setColor(cacheout_color)

#ADD "version" Pram
ptg = file_cache.parmTemplateGroup()
version = hou.IntParmTemplate("ver", "version", 1, default_value=(1,), min=1, max=99)
ptg.insertAfter("file", version)
file_cache.setParmTemplateGroup(ptg)


output_driver = hou.node('/obj/ropnet1').createNode('geometry')
output_driver.moveToGoodPosition()
output_driver.setName(source_node.name())
output_driver.setParms({'soppath':source_node.path()})
output_driver.setParms({'sopoutput':'`chs(\"' + file_cache.path() + '/file")`'})
output_driver.setColor(cacheout_color)

file_loader = source_node.parent().createNode('file')
file_loader.setInput(0, file_cache, 0)
file_loader.moveToGoodPosition()
file_loader.setInput(0, None, 0)


file_loader.setName('loadback_' + file_cache.name())
#file_loader.parm('file').setExpression('chs("' + output_driver.path() + '/sopoutput")')
file_loader.setParms({'file':'`chs(\"../' + file_cache.name() + '/file")`'})
source_node_out.setInput(0, file_loader, 0)
source_node_out.moveToGoodPosition()

'''

file_loader_time = source_node.parent().createNode('timeshift')
file_loader_time.setInput(0, file_loader, 0)
file_loader_time.moveToGoodPosition()
file_loader_null = source_node.parent().createNode('null')
file_loader_null.setInput(0, file_loader_time, 0)
file_loader_null.moveToGoodPosition()
#file_loader.null('OUT_' + source_node.name())
'''

No comments:

Post a Comment