import hou
list = hou.selectedNodes()
for i in list:
pyS = i.parm("prerender")
toChange = pyS.eval()
tmp = toChange + "\n" + "hou.parm('/obj/RENDER_Neige1/vm_pointscale').set(1)"
pyS.set(tmp)
import hou
import os
import glob
from arnold import *
node = hou.pwd()
geo = node.geometry()
assPath = node.parm("../ass").eval()
print assPath
AiBegin()
AiMsgSetConsoleFlags(AI_LOG_ALL)
AiASSLoad(assPath,AI_NODE_ALL)
# Iterate over all shape nodes, which includes procedural nodes
iter = AiUniverseGetNodeIterator(AI_NODE_SHAPE);
while not AiNodeIteratorFinished(iter):
node = AiNodeIteratorGetNext(iter)
# Is the node a procedural?
if AiNodeIs( node, "polymesh" ):
data = AiNodeGetPtr( node, "shader" )
name = AiNodeGetStr( node, "name" )
#shader = AiNodeGetArray( node, "shader" )
if len(name)>0:
print (name)
print (data)
shaderName = AiNodeGetStr( data, "name" )
print(shaderName)
packname =hou.node('/obj/crowdTwo/crowd_Source1').geometry().findGlobalAttrib("packname")
packname = packname.strings()[0]
if packname == "packOne":
style = 0
elif packname == "packTwo":
style = 1
def autoCop():
from yUtil import getCam
import nodesearch
import hou
#color
black=hou.Color((0,0,0))
list = hou.node("/obj").allSubChildren() #recherche les nodes cgMantra
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/") #le chemin out et un copNet si il n existe pas
if hou.node('/out/autoCop') == None:
copnet = net.createNode("cop2net","autoCop")
else :
copnet = hou.node('/out/autoCop/')
camPath = getCam() # aller rechercher l info backPlate dans la cam
cam = hou.node(camPath)
backPlateParm = cam.parm("vm_background")
if (hou.node('/out/autoCop/backPlate')) == None: # backplate if dont exist et set
backPlate = copnet.createNode("file","backPlate")
backPlate.parm("filename1").setFromParm(backPlateParm)
backPlate.setColor(black)
backPlate.setRenderFlag(True)
# remplir autocop
list = [] #recuperre tout les cgmantra
for node in match.nodes(net,recursive =True):
list.append(node.name())
preSelect=[] #verifie qui est deja dans autoCop et update image path
for i in list:
if hou.node("/out/autoCop/"+"/"+i+"/")==None:
preSelect.append(list.index(i))
else :
outputPath = hou.node("/out/"+i).parm("vm_picture")
fileCopNode = hou.node("/out/autoCop/"+"/"+i+"/")
fileCopNode.parm("filename1").setFromParm(outputPath) # maj path
selListe=[]
if len(preSelect) > 0 :
selListe= hou.ui.selectFromList(list,preSelect,clear_on_cancel=True) #ui select list
for i in selListe:
name = list[i]
outputPath = hou.node("/out/"+name).parm("vm_picture")
fileCopNode = hou.node("/out/autoCop/"+"/"+name+"/")
if fileCopNode == None : #si le node de rendu existe pas creer
child = hou.node('/out/autoCop').children()
for i in child: #check for render flag in child
if i.isGenericFlagSet(hou.nodeFlag.Render) is True:
lastNode = i
fileCop= copnet.createNode("file",name) # creer file dans autoCop
add = lastNode.createOutputNode("add","add")
add.setInput(1,fileCop,0)
add.setName("add_"+add.input(1).name())
add.setRenderFlag(True)
fileCopNode=fileCop
fileCopNode.parm("filename1").setFromParm(outputPath) # set path
def updateAutoCop():
import nodesearch
import hou
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/") #le chemin out et un copNet si il n existe pas
# remplir autocop
list = [] #recuperre tout les cgmantra
for node in match.nodes(net,recursive =True):
list.append(node.name())
for i in list:
if hou.node("/out/autoCop/"+"/"+i+"/")!=None:
outputPath = hou.node("/out/"+i).parm("vm_picture")
fileCopNode = hou.node("/out/autoCop/"+"/"+i+"/")
fileCopNode.parm("filename1").setFromParm(outputPath) # maj path
def copyPasteNuke():
import yUtil
reload(yUtil)
import nodesearch
import hou
#color
list = hou.node("/obj").allSubChildren() #recherche les nodes cgMantra
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/") #le chemin out et un copNet si il n existe pas
list = [] #recuperre tout les cgmantra
for node in match.nodes(net,recursive =True):
list.append(node.name())
selListe= hou.ui.selectFromList(list)
prefix = """
Read {
file """
suffix = """
localizationPolicy off
}"""
clipboard = ""
for i in selListe:
name = list[i]
outputPath = hou.node("/out/"+name).parm("vm_picture").eval()
clipboard += prefix + outputPath[:-8]+"%04d.exr" + suffix
popup = hou.ui.readInput("faire ctrl+c puis ctrl+v dans nuke",initial_contents=clipboard)
from os import listdir,path,system,environ
# node courant
myPath = hou.pwd()
# parent deux niveau au dessus
parent = str(myPath.parent().parent().path())
import nodesearch
#cherche par hda
matchType = nodesearch.NodeType("*texture::2.0")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node(parent+"/")
ext = "exr"
toExt = "rat"
for node in match.nodes(net,recursive =True):
map = node.parm("map").eval()
if map[-3:]== ext :
ratMap = map[:-3]+ toExt
node.parm("map").set(ratMap)
print ("rename -> " +ratMap)
import hou
def changeP():
# node roots
cNode = kwargs["node"].parent().path()
rootsPath= hou.parm(cNode+'/nodeRoots').eval()
oldPath= hou.parm(cNode+'/oldPath').eval()
newPath= hou.parm(cNode+'/newPath').eval()
# recup la liste des node a un endroit donner
nodeRoots=hou.node(rootsPath)
child = nodeRoots.allSubChildren()
# pour chaque node
for c in child:
# recup la liste des parmetre
parms = c.allParms()
#pour parm in parmListe:
for p in parms:
type = p.parmTemplate().type()
if str(type) == "parmTemplateType.String":
if oldPath in p.eval():
newString = p.eval().replace(oldPath,newPath)
setP = p.set(newString)
print p.eval()
changeP()
import OpenEXR
import os
roots = "//stord/diskd/BDD/crowd_bank/testText/"
dirPath = roots
result = next(os.walk(dirPath))[2]
imgInvalid = []
for i in result:
if i[-3:]== "exr" :
try:
image = OpenEXR.InputFile(roots+i)
if image.isComplete():
print 'Valid image'
else:
print 'Invalid image'
imgInvalid.append(i)
image.close()
except:
imgInvalid.append(i)
selListe= hou.ui.selectFromList(imgInvalid,clear_on_cancel=True) #ui select list
for t in selListe:
os.remove(roots+imgInvalid[t])
print imgInvalid[t] + " ... a ete supprime"
#https://excamera.com/articles/26/doc/openexr.html#OpenEXR.InputFile.isComplete
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
color =node.inputAncestors()[0]
r=color.parm("colorr").eval()
g=color.parm("colorg").eval()
b=color.parm("colorb").eval()
myColor = hou.Color((r,g,b))
color.setColor(myColor)
# exemple de code python
#color
print ("debut")
rootsM = "/obj/chaiseLongue/mantra_mat"
rootsN = hou.node(rootsM)
nodes = hou.selectedNodes()
import nodesearch
matchType = nodesearch.NodeType("arnold::image")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
for node in nodes:
#textL = []
nPath = node.path()
searchP = node
name = node.name()
nMat = rootsN.createNode("cgMaterial",name)
nMat.parm("udimsCheck").set(1)
child = node.children()
for nodeF in child:
print ("cild_" + nodeF.name())
print (nodeF.type())
if nodeF.type().nameComponents()[2] == "image":
print("text type "+nodeF.name())
textN = nodeF.name()
#texL.append(nodeF.parm('filename').eval())
textP = nodeF.parm('filename').eval()
createT = nMat.createNode("texture",textN)
createT.parm("map").set(textP)
print("fin")
import hou, os
iconvert = hou.getenv("HFS") + "/bin/" +"iconvert.exe"
iconvert = os.path.abspath(iconvert)
folder = hou.ui.selectFile(title='Images Folder', file_type=hou.fileType.Directory)
folder = hou.expandString(folder)
files = os.listdir(folder)
dot = "."
extension = "rat"
exts = ('.exr', '.jpg', '.tga', '.png','.tif', '.hdr')
def rat_folder():
for file in files:
realName = os.path.abspath( folder + file)
file_ext = realName[-4:]
if file_ext in exts:
export = iconvert + " " + realName + " " + realName[:-4] + dot + extension
exists = os.path.exists(realName[:-4] + dot + extension)
if exists is True:
status = "File exists. Skipping..."
else:
os.system(export)
status = "Success!"
print "----------------------------------------------"
print "RAT FOLDER STATUS: " + status
print "original = " + realName
print "new =" + realName[:-4] + dot + extension
print "----------------------------------------------"
if folder != '':
safety = hou.ui.displayMessage("Are you sure you want to convert all images in " + folder + " ?", buttons=('Yes', 'No'))
if safety == 0 and folder != '':
rat_folder()
createCgNull
#get current pane
netEdit = hou.ui.paneTabUnderCursor()
#create node
nullName=hou.ui.readInput("donner un nom : ") [1]
if len(nullName) == 0:
nullName = "donner_un_nom"
# safe name
import re
nullName=re.sub("[^0-9a-zA-Z\.]+", "_", nullName)
#create cgNull with safe name
myNull = currentNode.createOutputNode("CG::cgnull::0.0",nullName)
#get cursor pos
pos = netEdit.cursorPosition()
myNull.setPosition(pos)
myNull.move([-0.5, -1])
currentNode.setGenericFlag(hou.nodeFlag.DisplayComment,True)
renderName = str(myNull.name())+"_cache"
currentNode.setName(renderName)
if currentNode.parm("lecture").eval():
myNull.destroy()
Get-ChildItem -Directory -filter ifds -path E:\diskd\tempete*\houdini\fx\jmargelin*** | % { $_.FullName }
geo=hou.node("./IN_shapes").geometry()
menuList=[]
for point in geo.iterPoints():
name=point.attribValue("name")
if not name in menuList:
menuList.append(name)
menuList.append(name)
return menuList
for point in node.geometry().points():
position = point.position()
print (position)
#oncreated hda
currentNode = kwargs["node"]
import nodesearch
version = 12
list = hou.node("/obj").allSubChildren()
#rendu
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/")
#self.listSort()
for node in match.nodes(net,recursive =True):
node.parm("version").set(version)
import maya.cmds as cmds
# Get the list of all shape nodes in the scene
shape_nodes = cmds.ls(type='shape')
print(shape_nodes)
# Iterate over each shape node
for shape_node in shape_nodes:
# Get the name of the shader that is assigned to the shape node
try:
shader_name = cmds.listConnections(shape_node, type='shadingEngine')[0]
# Rename the shape node to include the name of the shader
new_shape_name = shape_node + "_" + shader_name
cmds.rename(shape_node, new_shape_name)
except:
print("No Shader Found for {}".format(shape_node))
import sys
import PySide2.QtWidgets as cul
app = cul.QApplication(sys.argv)
lab= cul.QLabel()
lab.show()
sys.exit(app.exec_())
import OpenEXR
header = OpenEXR.InputFile(hou.parm("vm_picture")).header()
header['pixelAspectRatio'] = 2.0
from os import listdir,path,system,environ,walk
# node courant
myPath = hou.pwd()
parent = str(myPath.parent().path())
print parent
textList = [
hou.parm(parent+"/texture_diffuse_base_color/map").eval(),
hou.parm(parent+"/texture_roughness/map").eval(),
hou.parm(parent+"/texture_normal/map").eval()
]
print textList[0]
ext = "exr"
for i in textList:
if len(i)>1:
print "cool"
pathSplit= i.split("/")
roots = "/".join(pathSplit[:-1]) + "/"
print roots
dirPath = roots
result = next(walk(dirPath))[2]
print result
for file in result:
if file[-3:]==ext:
file = roots + file
print file
system("iconvert "+file+" "+file[:-3]+"rat")
ratMap = file[:-3]+"rat"
print ("...")
print ("convert to -> "+ratMap)
break
from os import listdir,path,system,environ,walk
myPath = hou.pwd()
parent = str(myPath.parent().parent().path())
import nodesearch
matchType = nodesearch.NodeType("*cgMaterial*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node(parent+"/")
for node in match.nodes(net,recursive =True):
print node.path()
parent = str(node.path())
print parent
textList = [
hou.parm(parent+"/texture_diffuse_base_color/map").eval(),
hou.parm(parent+"/texture_roughness/map").eval(),
hou.parm(parent+"/texture_normal/map").eval()
]
print textList[0]
ext = "exr"
for i in textList:
if len(i)>1:
print "cool"
pathSplit= i.split("/")
roots = "/".join(pathSplit[:-1]) + "/"
print roots
dirPath = roots
result = next(walk(dirPath))[2]
print result
for file in result:
if file[-3:]==ext:
file = roots + file
print file
system("iconvert "+file+" "+file[:-3]+"rat")
ratMap = file[:-3]+"rat"
print ("...")
print ("convert to -> "+ratMap)
break
import os
dir = '//storf/diskf/SoudainSeuls/setup-station/RC/OUT/test/'
list = os.listdir(dir)
print list
for i in list:
source = dir + i
tmp = i.split("_")
nName = tmp[0] + "_" + tmp[1] + "." + tmp[2]
destination = dir + nName
print (source)
os.rename (source,destination)
import os
dir= "//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/texture/name/"
for f in os.listdir(dir):
oldf = f
f = f.split("_")
f[0] = f[0].lower() + f[1]
f.pop(1)
newF = "_".join(f)
print oldf
print newF
os.rename(dir+oldf,dir+newF)
import hou
list = hou.selectedNodes()
for i in list:
pyS = i.parm("prerender")
toChange = pyS.eval()
tmp = toChange.replace("15","25")
pyS.set(tmp)
import hou
def cgevResetTheDay():
import nodesearch
list = hou.node("/obj").allSubChildren()
for i in list:
if i.type().name()== "cam":
camPath= i.path()
break
else :
camPath="/obj/cam1"
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/")
#self.listSort()
for node in match.nodes(net,recursive =True):
node.parm("version").pressButton()
node.parm("version").set(1)
node.parm("camera").set(camPath)
hou.parm('/obj/foule_fx/frustrum/camera').set(camPath)
cgevResetTheDay()
def cgevResetTheDay():
import nodesearch
matchType = nodesearch.NodeType("CG::renderGeo*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/obj/")
list = hou.node("/obj").allSubChildren()
for i in list:
if i.type().name()== "cam":
camPath= i.path()
break
else :
camPath="/obj/cam1"
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/")
#self.listSort()
for node in match.nodes(net,recursive =True):
node.parm("version").pressButton()
node.parm("version").set(1)
node.parm("camera").set(camPath)
hou.parm('/obj/foule_fx/frustrum/camera').set(camPath)
for node in match.nodes(net,recursive =True):
hou.parm(node.path()+'/version').pressButton()
hou.parm(node.path()+'/version').set(1)
cgevResetTheDay()
import hou
def cgevResetTheDay():
import nodesearch
list = hou.node("/obj").allSubChildren()
for i in list:
if i.type().name()== "cam":
camPath= i.path()
break
else :
camPath="/obj/cam1"
matchType = nodesearch.NodeType("CG::cgmantra*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/out/")
#self.listSort()
for node in match.nodes(net,recursive =True):
node.parm("version").pressButton()
node.parm("version").set(1)
node.parm("camera").set(camPath)
hou.parm('/obj/foule_fx/frustrum/camera').set(camPath)
matchType = nodesearch.NodeType("CG::renderGeo*")
matchName = nodesearch.Name("*")
match = nodesearch.Group([matchType,matchName])
net = hou.node("/obj/")
for node in match.nodes(net,recursive =True):
hou.parm(node.path()+'/version').pressButton()
hou.parm(node.path()+'/version').set(1)
cgevResetTheDay()
from PIL import Image
import os
import PIL
import glob
imgRoots = '//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/textureLow/'
subFolder = "/femme01/"
roots= r"//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/textureLow"+subFolder+"0/Mantra/"
dirPath = roots
result = next(os.walk(dirPath))[2]
print(result)
for img in result:
image = Image.open(roots+img)
resized_image = image.resize((1024,1024))
resized_image.save(roots+img)
from PIL import Image
import os
import PIL
import glob
imgRoots = '//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/textureLow/'
listFemme = ["02","07","08","11","12"]
listHomme = ["01","02","04","05","06","10","15","16","18","20","21","22","23"]
for elem in listFemme :
subFolder = "/femme"+elem+"/"
sousDos = next(os.walk(imgRoots+subFolder))[1]
roots= r"//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/textureLow"+subFolder+"0/Mantra/"
dirPath = roots
result = next(os.walk(dirPath))[2]
for i in sousDos:
roots = r"//stord/diskd/BDD/crowd_bank/hyppodrome_tempete/textureLow"+subFolder+i+"/Mantra/"
for img in result:
image = Image.open(roots+img)
resized_image = image.resize((1024,1024))
resized_image.save(roots+img)
import re
nullName=re.sub("[^0-9a-zA-Z\.]+", "_", nullName)
import hou
list = hou.selectedNodes()
for i in list:
camP = i.parm("camera").eval()
cam = hou.node(camP)
cam.parm("shutter").deleteAllKeyframes()
cam.parm("shutter").set(0.3)
"""
import sys
sys.path.append('//stord/diskd/tempete/setup-foule/houdini/fx/jmargelin/setup-foule_fx_seqFinMultiCam_jmargelin/scripts')
import fullNeige as fullNeige
reload(fullNeige)
"""
from lxml import etree
xmlPath = "//stord/diskd/BDD/xmlFile/backup/testClean.xml"
tree = etree.parse(xmlPath)
tronc = tree.getroot()
myList=[]
for i in tronc:
if i.attrib['name']=='eightForSilver':
parent = i.getparent()
parent.remove(i)
myList=sorted(myList)
tree.write("//stord/diskd/BDD/xmlFile/backup/testClean.xml")
VEX