sexta-feira, 1 de junho de 2018

User Attributes from maya to Houdini using Alembic


In Maya create a new attribute inside  your object transform node and fill it up with your data   
Go inside Alembic options . add your attribute using channel box or just write down inside attribute box and prefix box . then inside Houdini will be  possible access this attribute from disk using python expression 


import _alembic_hom_extensions as abc 
import hou 
value = abc.alembicArbGeometry("/Volumes/Raid0/GREEN/HOUDINI/USERS/LUCAS/abc/INFO.abc","CAM_EXTRA_","zoom",hou.frame() /24)[0][0]
return(value)


command Usage:
alembicArbGeometry("filePath","objPath" , "userAttribute" , sample time )

actually this command return a tuple of values , we are just looking for inside values,  that's why 
we add [0[[0] at the end

terça-feira, 20 de março de 2018

Python CacheManager for houdini

Python scripts to copy files to another folder if its greater then maximus capacity .
Source this functions using  Houdini by Python Source Editor  then write down  this line in your Pre-Frame Script using python as main language

    hou.session.cacheCopyManager(hou.node('/out/geometry1'), 890409 , "/home/chrysl666/PROJECTS/TEMP")

this function needs a path to the ROP node , a maximus Size in bytes  and the destination folder


script code :



# python scripts to copy files to another folder if its greater then maximus capacity
# source this functions using  Houdini by Python Source Editor
# then put this line in your Pre-Frame Script
#
#     hou.session.cacheCopyManager(hou.node('/out/geometry1'), 890409 , "/home/chrysl666/PROJECTS/TEMP")
#
#     this function needs a path to the ROP node , a maximus Size in kbits 
#     and the destination folder


#get total size of a folder in Kbytes
def get_size(startDirPath):
    import os
   
    total_size = 0
    for dirpath, dirnames, filenames in os.walk(startDirPath):
        for f in filenames:
            fp = os.path.join(dirpath, f)
            total_size += os.path.getsize(fp)
    return total_size

#copy files from a folder to another one
def copyCurrentCache(dirPath , dest ):
    import os
    import shutil

    src_files = os.listdir(dirPath)

    for file_name in src_files:
        full_file_name = os.path.join(dirPath, file_name)
        if (os.path.isfile(full_file_name)):
            shutil.copy(full_file_name, dest)
           

#remove old files from a folder
def removeOldCache(dirPath):
    import os
   
    filelist = [ f for f in os.listdir(dirPath) if f.endswith(".sc") ]
    for f in filelist:
        os.remove(os.path.join(dirPath, f))

# main function for managing cache folder size
def cacheCopyManager(ropNode , maxsize , dest):
    import os
    import hou
   
    #get cacheFolderPath
    outFileParm = ropNode.evalParm("sopoutput")
    dirPath = os.path.split(outFileParm)
   
    #get cacheFolder size in Kb
    dirSize = hou.session.get_size(dirPath[0])
   
    #check if it greather then maxi size
    if dirSize >= maxsize :
        print dirSize
        #if its greather then copy to another folder and delete oldCache
        hou.session.copyCurrentCache(dirPath[0] , dest)
        hou.session.removeOldCache(dirPath[0])

sexta-feira, 28 de julho de 2017

Append new path in python

just use sys.path.appenf()
in this case  i have a folder named  chrysl666toolkit
and a empty __init__py  and the main code itself inside cacheCommander.py



import sys
sys.path.append("/home/chrysl666/HoudiniProjects/MIX/chrysl666toolkit")
import cacheCommander

domingo, 29 de janeiro de 2017

quarta-feira, 25 de janeiro de 2017

Houdini Export and import Nodes tool

Houdini Export and import Node tool
my first useful tool for houdini . helps to speed up exporting and importing between student to commercial version .. pretty simple code and colorize nodes based on posfix string ....just put into your shelf !! and run it

posfix string :
emitter = EMITT
geometry = GEO
pyro_import = SIMOUT
lights = LGT
camera = cam
pyro_sim = SIM
sink object = SINK
pump object =PUMP
expansion object = EXP
collision obj = COLL



source code :



  1. #import Qt modules using PySide 
  2. from PySide import QtCore
  3. from PySide import QtGui


  4. #create hiptools class window using  QWidget/QtGui  base class 
  5. class hipTools(QtGui.QWidget):
  6.     def __init__(self, parent=None):
  7.         QtGui.QWidget.__init__(self, parent)
  8.         
  9.         #layout
  10.         colorsHLayout  = QtGui.QHBoxLayout()
  11.         exportImportHLayout  = QtGui.QHBoxLayout()
  12.         mainVLayout = QtGui.QVBoxLayout()

  13.         # windows size and title 
  14.         self.setGeometry(300, 300, 250, 110)
  15.         self.setWindowTitle('Hip Tools')
  16.         self.setStyleSheet("background-color: grey")
  17.         

  18.         #labels
  19.         expImpLabel = QtGui.QLabel('Export import Nodes')
  20.         colNodesLabel =  QtGui.QLabel('Colorize Nodes')
  21.         
  22.         #buttons
  23.         exportButton = QtGui.QPushButton('Export Nodes ', self)
  24.         exportButton.setStyleSheet("color:black ; background-color: orange")
  25.         
  26.         importButton = QtGui.QPushButton('Import Nodes ', self)
  27.         importButton.setStyleSheet("color:black ; background-color: orange")
  28.         
  29.         colorsButton = QtGui.QPushButton('Colorize Nodes ', self)
  30.         colorsButton.setStyleSheet("color:black ; background-color: orange")

  31.         #insert into layout 
  32.         mainVLayout.addWidget(expImpLabel)
  33.         exportImportHLayout.addWidget(exportButton)
  34.         exportImportHLayout.addWidget(importButton)
  35.         mainVLayout.addLayout(exportImportHLayout)
  36.         
  37.         mainVLayout.addWidget(colNodesLabel)
  38.         colorsHLayout.addWidget(colorsButton)
  39.         mainVLayout.addLayout(colorsHLayout)
  40.         
  41.         #set main window base layout 
  42.         self.setLayout(mainVLayout)
  43.         
  44.         #connect SIGNALS and SLOTS 
  45.         self.connect(exportButton, QtCore.SIGNAL('clicked()'), self.exportNodes)
  46.         self.connect(importButton , QtCore.SIGNAL('clicked()'), self.imprtNodes)
  47.         self.connect(colorsButton , QtCore.SIGNAL('clicked()'), self.colorNodes)
  48.         
  49.         
  50.         
  51.         
  52.         
  53.     # define export and import member functions 
  54.     def exportNodes(self):
  55.     
  56.         #call file dialog
  57.         exprtData = self.getExportfolder()
  58.         #export
  59.         hou.hscript('opscript -G -r / > ' +exprtData[0])
  60.         print exprtData[0]
  61.         
  62.         #close window 
  63.         self.close()

  64.         
  65.         
  66.     def imprtNodes(self):
  67.         
  68.         #call file dialog
  69.         imprtData = self.geImprtfolder()
  70.         #import
  71.         hou.hscript('cmdread ' + imprtData[0])
  72.         print imprtData[0]
  73.         
  74.         #close window 
  75.         self.close()
  76.             
  77.     
  78.     
  79.     
  80.     
  81.     # export dialog 
  82.     def getExportfolder(self):

  83.         #get filename and path to export data 
  84.         return QtGui.QFileDialog.getSaveFileName()
  85.         
  86.     # import dialog 
  87.     def geImprtfolder(self):
  88.         
  89.         #get filename and path to export data 
  90.         return QtGui.QFileDialog.getOpenFileName()




  91. # chrysl666  color Node Color  Util

  92.     def colorNodes(self):
  93.         #define Colors dict
  94.         colors = { "lightBlue":hou.Color((0,0.6,1)),
  95.             "lightGreen":hou.Color((0,0.533,0)), 
  96.            "green":hou.Color( (0,1,)) ,
  97.            "blue":hou.Color( (0,0,1)) ,
  98.            "yellow":hou.Color((1,0.8,0)),
  99.            "black":hou.Color((0,0,0)),
  100.            "grey":hou.Color((0.36,0.36,0.36)),
  101.            "purple":hou.Color( (0.4,0,0.6) )
  102.            }
  103.         
  104.         
  105.         # get all nodes in Obj context
  106.         rootNode = hou.node('/obj')
  107.         rootChildren = rootNode.children()
  108.         
  109.         for child in rootChildren:
  110.             currentName = child.name()
  111.             
  112.             #Geo Nodes
  113.             if currentName.endswith("EMITT"):
  114.                 child.setColor( colors["lightBlue"] )
  115.             
  116.             if currentName.endswith("GEO"):
  117.                 child.setColor( colors["lightBlue"] )
  118.             #Render Nodes
  119.             if currentName.endswith("SIMOUT"):
  120.                 child.setColor(colors["lightGreen"] )
  121.             
  122.             if currentName.endswith("LGT"):
  123.                 child.setColor( colors["yellow"] )
  124.                     
  125.             if currentName.startswith("cam"):
  126.                 child.setColor( colors["grey"] )
  127.             
  128.             #Simulation Nodes
  129.             if currentName.endswith("SIM"):
  130.                 child.setColor( colors["purple"] )    
  131.             if currentName.endswith("SINK"):
  132.                 child.setColor( colors["black"] )
  133.             if currentName.endswith("PUMP"):
  134.                 child.setColor( colors["black"] )
  135.             if currentName.endswith("EXP"):
  136.                 child.setColor( colors["black"] )
  137.             if currentName.endswith("COLL"):
  138.                 child.setColor( colors["black"] )
  139.             if currentName.endswith("EXP"):
  140.                 child.setColor( colors["black"] )
  141.             self.close()
  142.                    
  143.         
  144.  
  145.         
  146. # run app           
  147. hipToolsWin = hipTools()
  148. hipToolsWin.show()


quinta-feira, 5 de janeiro de 2017

quarta-feira, 4 de janeiro de 2017

converting hipc to hip houdini

opscript
cmdread
This is an example of usage.
opscript -G -r / > F:/un/objgroups.cmd
And when load all generated .cmd back.
cmdread F:/un/groups.cmd
I didn’t test it with locked digital assets. According to documentation it won’t work.

info  get from  https://kiko3d.wordpress.com/2015/03/19/converting-houdini-not-commercial-files/