Пример #1
0
    def _import_project(path):
        """
        Import a katana project into the current session.

        :param path: The file path to import.
        :type path: str
        """
        root = NodegraphAPI.GetRootNode()
        return KatanaFile.Import(path, floatNodes=True, parentNode=root)
Пример #2
0
def import_katana_scene(katana_scene):
    '''
    :description to import the katana scene
    :param katana_scene <str>
    :example
        from core import scene
        katana_scene = '/venture/shows/katana_tutorials/tmp/export_03.katana'
        scene.import_katana_scene(katana_scene)      
    '''
    if not os.path.isfile(katana_scene):
        print '#warnings: not found katana scene'
        return
    knodes = KatanaFile.Import(katana_scene, floatNodes=False)
    print '#info: import nodes'
    for knode in knodes:
        print '\t', knode.getName()
    return True
Пример #3
0
    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!')
Пример #4
0
 def displayOpenDialog(self):
     fname = str(
         QFileDialog.getOpenFileName(self, 'Open file',
                                     '/s/prodanim/asterix2',
                                     "Katana files (*.katana)"))
     if fname == '':
         print 'No file has been open'
     if self.sender().objectName() == 'openAction':
         KatanaFile.Load(fname)
         print 'Loading : ' + fname
     else:
         currentSelection = NodegraphAPI.GetAllSelectedNodes()
         #deselect all the node to select only the 2 created nodes and put them floating under the mouse
         for node in currentSelection:
             NodegraphAPI.SetNodeSelected(node, False)
         KatanaFile.Import(fname, floatNodes=True)
         print 'importing : ' + fname
         nodeList = NodegraphAPI.GetAllSelectedNodes()
         # Find Nodegraph tab and float nodes
         nodegraphTab = Tabs.FindTopTab('Node Graph')
         if nodegraphTab:
             nodegraphTab.floatNodes(nodeList)
Пример #5
0
    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))
Пример #6
0
def import_file(log, fname=None, as_reference=False):
    if fname is None or not os.path.exists(fname):
        log.error("Invalid file path given for import: %s", fname)
        return False

    if HOST == STANDALONE:
        from tentaculo.api import standalone
        standalone.message_function("import_file", [fname, as_reference])
    elif HOST == MAYA or HOST == MAYA2:
        log.debug("Import: Maya %s", fname)
        if as_reference:
            file_path = mc.file(fname,
                                reference=True,
                                mergeNamespacesOnClash=True)
            mc.file(file_path, selectAll=True)
        else:
            before = mc.ls()
            mc.file(fname, i=True, mergeNamespacesOnClash=True)
            after = mc.ls()
            selection = [x for x in after if x not in before]
            mc.select(selection)
    elif HOST == NUKE:
        log.debug("Import: Nuke %s", fname)
        if as_reference:
            nuke.nodes.Read(file=fname)
    elif HOST == HOUDINI:
        log.debug("Import: Houdini %s", fname)
        if as_reference:
            pass
        else:
            hou.hipFile.merge(fname)
    elif HOST == MAX:
        log.debug("Import: 3ds Max %s", fname)
        if as_reference:
            pass
        else:
            MaxPlus.FileManager.Merge(fname, True, True)
    elif HOST == C4D:
        log.debug("Import: C4D %s", fname)
        doc = c4d.documents.GetActiveDocument()
        if doc is not None:
            if as_reference:
                pass
            else:
                c4d.documents.MergeDocument(doc, fname)
    elif HOST == BLENDER:
        log.debug("Import: Blender %s", fname)
        with bpy.data.libraries.load(filepath=fname,
                                     link=as_reference) as (data_from,
                                                            data_to):
            #data_to.objects = data_from.objects
            for attr in dir(data_to):
                setattr(data_to, attr, getattr(data_from, attr))

        for obj in data_to.objects:
            if obj is not None:
                bpy.context.scene.objects.link(obj)
                obj.select = True
    elif HOST == KATANA:
        if as_reference:
            pass
        else:
            KatanaFile.Import(fname)

    return True