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 :
- #import Qt modules using PySide
- from PySide import QtCore
- from PySide import QtGui
- #create hiptools class window using QWidget/QtGui base class
- class hipTools(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- #layout
- colorsHLayout = QtGui.QHBoxLayout()
- exportImportHLayout = QtGui.QHBoxLayout()
- mainVLayout = QtGui.QVBoxLayout()
- # windows size and title
- self.setGeometry(300, 300, 250, 110)
- self.setWindowTitle('Hip Tools')
- self.setStyleSheet("background-color: grey")
- #labels
- expImpLabel = QtGui.QLabel('Export import Nodes')
- colNodesLabel = QtGui.QLabel('Colorize Nodes')
- #buttons
- exportButton = QtGui.QPushButton('Export Nodes ', self)
- exportButton.setStyleSheet("color:black ; background-color: orange")
- importButton = QtGui.QPushButton('Import Nodes ', self)
- importButton.setStyleSheet("color:black ; background-color: orange")
- colorsButton = QtGui.QPushButton('Colorize Nodes ', self)
- colorsButton.setStyleSheet("color:black ; background-color: orange")
- #insert into layout
- mainVLayout.addWidget(expImpLabel)
- exportImportHLayout.addWidget(exportButton)
- exportImportHLayout.addWidget(importButton)
- mainVLayout.addLayout(exportImportHLayout)
- mainVLayout.addWidget(colNodesLabel)
- colorsHLayout.addWidget(colorsButton)
- mainVLayout.addLayout(colorsHLayout)
- #set main window base layout
- self.setLayout(mainVLayout)
- #connect SIGNALS and SLOTS
- self.connect(exportButton, QtCore.SIGNAL('clicked()'), self.exportNodes)
- self.connect(importButton , QtCore.SIGNAL('clicked()'), self.imprtNodes)
- self.connect(colorsButton , QtCore.SIGNAL('clicked()'), self.colorNodes)
- # define export and import member functions
- def exportNodes(self):
- #call file dialog
- exprtData = self.getExportfolder()
- #export
- hou.hscript('opscript -G -r / > ' +exprtData[0])
- print exprtData[0]
- #close window
- self.close()
- def imprtNodes(self):
- #call file dialog
- imprtData = self.geImprtfolder()
- #import
- hou.hscript('cmdread ' + imprtData[0])
- print imprtData[0]
- #close window
- self.close()
- # export dialog
- def getExportfolder(self):
- #get filename and path to export data
- return QtGui.QFileDialog.getSaveFileName()
- # import dialog
- def geImprtfolder(self):
- #get filename and path to export data
- return QtGui.QFileDialog.getOpenFileName()
- # chrysl666 color Node Color Util
- def colorNodes(self):
- #define Colors dict
- colors = { "lightBlue":hou.Color((0,0.6,1)),
- "lightGreen":hou.Color((0,0.533,0)),
- "green":hou.Color( (0,1,)) ,
- "blue":hou.Color( (0,0,1)) ,
- "yellow":hou.Color((1,0.8,0)),
- "black":hou.Color((0,0,0)),
- "grey":hou.Color((0.36,0.36,0.36)),
- "purple":hou.Color( (0.4,0,0.6) )
- }
- # get all nodes in Obj context
- rootNode = hou.node('/obj')
- rootChildren = rootNode.children()
- for child in rootChildren:
- currentName = child.name()
- #Geo Nodes
- if currentName.endswith("EMITT"):
- child.setColor( colors["lightBlue"] )
- if currentName.endswith("GEO"):
- child.setColor( colors["lightBlue"] )
- #Render Nodes
- if currentName.endswith("SIMOUT"):
- child.setColor(colors["lightGreen"] )
- if currentName.endswith("LGT"):
- child.setColor( colors["yellow"] )
- if currentName.startswith("cam"):
- child.setColor( colors["grey"] )
- #Simulation Nodes
- if currentName.endswith("SIM"):
- child.setColor( colors["purple"] )
- if currentName.endswith("SINK"):
- child.setColor( colors["black"] )
- if currentName.endswith("PUMP"):
- child.setColor( colors["black"] )
- if currentName.endswith("EXP"):
- child.setColor( colors["black"] )
- if currentName.endswith("COLL"):
- child.setColor( colors["black"] )
- if currentName.endswith("EXP"):
- child.setColor( colors["black"] )
- self.close()
- # run app
- hipToolsWin = hipTools()
- hipToolsWin.show()
Nenhum comentário:
Postar um comentário