Wednesday, June 26, 2024
[Python]Fill in the code in wangle by python
Tuesday, November 14, 2023
[Hython]Shows a list of default path.
How to display a list of directories where Houdini reads for Python files by default.
>>> import sys
>>> a = sys.path
>>> for i in a:
... print i
...
C:/PROGRA~1/SIDEEF~1/HOUDIN~1.759/python27/lib/site-packages-ui-forced
C:/Users/user01/Documents/houdini18.5/python2.7libs <------- I confirmed adding the directory.
Wednesday, January 12, 2022
[Hython] My shelf
◆◆◆◆New Tool◆◆◆◆
source_nodes = hou.selectedNodes() for m in source_nodes: allsub_nodes = m.allSubChildren() for n in allsub_nodes: if n.type().name() == 'file': print n.path() print n.evalParm('file') print '----'
Thursday, October 21, 2021
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.
Sunday, January 12, 2020
[Hython] Change a path on around alembic nodes
print "############################################################"
node = hou.pwd()
root = hou.node('/obj')
all_nodes = root.allSubChildren()
for n in all_nodes:
if n.type().name() == 'alembicarchive' or n.type().name() == 'alembic':
fp = n.evalParm('fileName')
fps = fp.split("/")
fpar = fps[-2:]
if fpar[0] == 'alembic':
fpn = '$CACHE/'+fpar[0]+'/'+fpar[1]
# n.parm('fileName').set(fpn)
print '<'+n.path()+'>'
print fpn
print n.evalParm('fileName')+'\n'
Friday, October 18, 2019
[Hython] File SOP Read Path
path = ch(“../pathToYourFileNode/file”).split('/')
file = path.pop().split('.')
Tuesday, July 23, 2019
[Hython] Change a path Linux to Windows
print "############################################################"
fp_bas = '/root/work/cache'
fp_tar = 'E:\work\cache'
fpn_tar = fp_tar.decode('ascii').replace(chr(92),'/')
root = hou.node('/')
all_nodes = root.allSubChildren()
for n in all_nodes:
if n.type().name() == 'filecache':
if not 'setLoader' in n.path():
fp = n.evalParm('file')
fpn = fp.replace(fp_bas,fpn_tar)
n.parm('file').set(fpn)
print n.path()
print fpn
print "----"
---------------------------
Reference HP: Thx a lot.
- Pythonで文字列を置換(replace, translate, re.sub, re.subn)https://note.nkmk.me/python-str-replace-translate-re-sub/
- Python で ¥ (円マーク)を直接指定して置換するには http://yoshidabenjiro.hatenablog.com/entry/2016/12/24/232150
- ascii code backslash https://theasciicode.com.ar/ascii-printable-characters/backslash-reverse-slash-ascii-code-92.html
Monday, July 15, 2019
[Hython] Change the forced some parameter of mantra node
parent = hou.node("/obj/ropnet1")
setting1 = 'vm_samplesx'
setting2 = 'vm_samplesy'
setting3 = 'vm_maxraysamples'
for child in parent.children():
param1 = child.parm(setting1)
param1.set(4)
param2 = child.parm(setting2)
param2.set(4)
param3 = child.parm(setting3)
param3.set(6)
"""
if sstring in child.name():
param = child.parm("matte_objects")
if param is None:
pass
else:
print searchStr
print replStr
param.set(temp)
"""
Reference HP; Thx a lot!
https://tosinakinwoye.com/2014/05/04/houdini-python-snippets/
https://qiita.com/7of9/items/5fb6d57ccb0ce9a47dd6
Saturday, June 15, 2019
[Hython] Listing file cache paths
------------------------------------------------
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
print "############################################################"
root = hou.node('/')
all_nodes = root.allSubChildren()
for n in all_nodes:
if n.type().name() == 'file' or n.type().name() == 'filecache':
if not 'setLoader' in n.path():
print n.path()
print n.evalParm('file')
print "----"
Tuesday, April 30, 2019
[Hython] sevral py code
import naming
source_node = hou.selectedNodes()[0]
output_driver = hou.node('/obj/ropnet1').createNode('geometry')
output_driver.moveToGoodPosition()
output_driver.setName(source_node.name())
output_driver.setParms({'soppath':source_node.path()})
naming.update_node_outpath(output_driver)
file_loader = source_node.parent().createNode('file')
file_loader.setInput(0, source_node, 0)
file_loader.moveToGoodPosition()
file_loader.setInput(0, None, 0)
file_loader.setName('loadback_' + source_node.name())
file_loader.parm('file').setExpression('chs("' + output_driver.path() + '/sopoutput")')
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())
-----Blast Separate By Connectivity
node = hou.selectedNodes()[0]
geo = node.geometry()
count = 0
merge = node.parent().createNode('merge')
value = max(geo.pointIntAttribValues('class'))
print value
for count in range(value+1):
blst_gp = "@class==" + str(count)
blast = node.parent().createNode('blast')
blast.setInput(0,node)
blast.moveToGoodPosition()
blast.parm('negate').set(True)
blast.parm('grouptype').set(3)
blast.parm('group').set(blst_gp)
pack = node.parent().createNode('pack')
pack.setInput(0,blast)
pack.moveToGoodPosition()
merge.setInput(count,blast,0)
merge.moveToGoodPosition()
merge.setDisplayFlag(True)
-----Blast Separate By Group
Wednesday, February 20, 2019
[Hython] Get upstream last number of node name.
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
thenumber = int(node.evalParm('opdigits'))
geo.addAttrib(hou.attribType.Point, "pos_id", thenumber)
Thursday, February 14, 2019
[Hython] add & set attribute
geo.addAttrib(hou.attribType.Point, "name", "")
-add Global or detail attribute
geo.addAttrib(hou.attribType.Global, "id", number)
-----------------------------------------
--add and set "name" attribute ex--
node = hou.pwd()
geo = node.geometry()
geo.addAttrib(hou.attribType.Point, "name", "")
for point in geo.points():
point.setAttribValue("name", "piece" + str(point.number()))
-----------------------------------------
https://forums.odforce.net/topic/31951-add-name-attribute-via-python/
-----------------------------------------
###memo: my cord
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
#t = target_node.inputs()
#for i in t:
# name = i.path()
# get_name = name.split("_")
# print name
# geo = hou.node(name).geometry()
thenumber = int(node.evalParm('opdigits'))
# geo.addAttrib(hou.attribType.Global, "pos_id", thenumber)
geo.addAttrib(hou.attribType.Point, "pos_id", thenumber)