def importKlf(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) currentItemName = str(self.listWidget.currentItem().text()) checkCat = str(self.catedoryCB.currentText()) if not checkCat == 'ALL': klfName = os.path.join(self.directory, checkCat, currentItemName + '.klf') expression = 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'.format( checkCat, currentItemName + '.klf') else: klfName = os.path.join( str(self.listWidget.currentItem().data( QtCore.Qt.UserRole).toPyObject()), currentItemName + '.klf') expression= 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'\ .format(str(self.listWidget.currentItem().data(QtCore.Qt.UserRole).toPyObject()).split(os.sep)[-1], currentItemName+'.klf') if os.path.exists(klfName): lfm = NodegraphAPI.CreateNode('LookFileMaterialsIn', NodegraphAPI.GetRootNode()) lfm.setName('LFMI_' + currentItemName) DrawingModule.SetCustomNodeColor(lfm, 0.4, 0, 0.15) lfm.getParameter('lookfile').setExpression(expression) NodegraphAPI.SetNodePosition(lfm, ((pos[0][0]), pos[0][1])) else: QtGui.QMessageBox.information( None, currentItemName, 'There is no Look File for {}, try importing Material!'.format( currentItemName))
def importLmtl(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) currentItemName = str(self.listWidget.currentItem().text()) checkCat = str(self.catedoryCB.currentText()) if not checkCat == 'ALL': klfName = os.path.join(self.directory, checkCat, currentItemName + '.klf') expression = 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'.format( checkCat, currentItemName + '.klf') else: klfName = os.path.join( str(self.listWidget.currentItem().data( QtCore.Qt.UserRole).toPyObject()), currentItemName + '.klf') expression= 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'\ .format(str(self.listWidget.currentItem().data(QtCore.Qt.UserRole).toPyObject()).split(os.sep)[-1], currentItemName+'.klf') if os.path.exists(klfName): materialNode = NodegraphAPI.CreateNode('Material', NodegraphAPI.GetRootNode()) materialNode.getParameter('name').setValue(currentItemName, 0) DrawingModule.SetCustomNodeColor(materialNode, 0.2, 0.27, 0.4) materialNode.getParameter('action').setValue( 'create from Look File', 0) materialNode.getParameter('lookfile.lookfile').setExpression( expression) NodegraphAPI.SetNodePosition(materialNode, ((pos[0][0]), pos[0][1])) materialAssign = NodegraphAPI.CreateNode( 'MaterialAssign', NodegraphAPI.GetRootNode()) materialAssign.setName('MA_' + currentItemName) materialAssign.getParameter( 'args.materialAssign.value').setExpression( "scenegraphLocationFromNode(getNode('{}'))".format( materialNode.getName())) DrawingModule.SetCustomNodeColor(materialAssign, 0.2, 0.27, 0.4) NodegraphAPI.SetNodePosition(materialAssign, ((pos[0][0]), pos[0][1] - 50)) materialNode.getOutputPort('out').connect( materialAssign.getInputPort('input')) NodegraphAPI.SetNodeEdited(materialAssign, edited=True, exclusive=True) else: QtGui.QMessageBox.information( None, currentItemName, 'There in no Look File for {}, try importing Material!'.format( currentItemName))
def createStandard(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) renderer = RenderingAPI.RenderPlugins.GetDefaultRendererPluginName() if renderer == 'arnold': fileName = os.path.join(self.resources, 'arnold_standard.katana') elif renderer == 'prman': fileName = os.path.join(self.resources, 'prman_standard.katana') else: QtGui.QMessageBox.warning( None, 'Error', '{} plugin not found!'.format(renderer.upper())) return if os.path.exists(fileName): KatanaFile.Import(fileName, floatNodes=False) imported = NodegraphAPI.GetAllSelectedNodes()[-1] NodegraphAPI.SetNodePosition(imported, ((pos[0][0]), pos[0][1])) else: QtGui.QMessageBox.warning(None, 'Error', 'There is no standard material saved!')
def createNode(node_type_string, auto_position=True): ''' create a type of node, and put that node in the center of the current focused group''' # get node graph widget ngw = getNodeGraphView() root = NodegraphAPI.GetRootNode() focused_node = getCurrentFocuseNode() if not focused_node: focused_node = root new_node = NodegraphAPI.CreateNode(node_type_string, focused_node) if auto_position: # view port center position in root node space # returned value lik ((815.5, -279.0, 10000.0), (1.0, 1.0, 1.0)) center = NodegraphAPI.GetViewPortPosition(root) # convert to group position pos = ngw.getPointAdjustedToGroupNodeSpace( focused_node, (center[0][0], center[0][1])) # put the node at the position NodegraphAPI.SetNodePosition(new_node, pos) # select this node NodegraphAPI.SetNodeSelected(new_node, True) else: placeNode(new_node) return new_node
def importMtl(self): pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode()) currentItemName = str(self.listWidget.currentItem().text()) checkCat = str(self.catedoryCB.currentText()) if not checkCat == 'ALL': fileName = os.path.join(self.directory, checkCat, currentItemName + '.katana') else: fileName = os.path.join( str(self.listWidget.currentItem().data( QtCore.Qt.UserRole).toPyObject()), currentItemName + '.katana') if os.path.exists(fileName): KatanaFile.Import(fileName, floatNodes=False) imported = NodegraphAPI.GetAllSelectedNodes()[-1] DrawingModule.SetCustomNodeColor(imported, 0.2, 0.4, 0.1) NodegraphAPI.SetNodePosition(imported, ((pos[0][0]), pos[0][1])) else: QtGui.QMessageBox.information( None, currentItemName, 'There is no Material for {}, try importing Look File!'.format( currentItemName))