Пример #1
0
 def referenceFile(self):
     maya_file = self.filepath_label.text()
     if maya_file:
         mFile = OpenMaya.MFileIO()
         mFile.reference(
             r"%s" % os.path.abspath(maya_file).replace("\\", "/"), False,
             False, os.path.basename(maya_file))
Пример #2
0
 def importFile(self, maya_file):
     if maya_file:
         mFile = OpenMaya.MFileIO()
         util = OpenMaya.MScriptUtil()
         ptr = util.asCharPtr()
         mFile.importFile(
             r"%s" % os.path.abspath(maya_file).replace("\\", "/"), None,
             False, None, False)
Пример #3
0
def scene_open(path, set_project):
    '''
    シーンを開く
    :return:
    '''
    def new_open():
        if set_project is True:
            cmds.workspace(project_path, openWorkspace=True)
        io.open(path, file_type, 1)
        add_rectnt_project(project_path)
        add_rectnt_file(path, file_type)

    types = {
        '.ma': 'mayaAscii',
        '.mb': 'mayaBinary',
        '.fbx': 'FBX',
        '.obj': 'OBJ'
    }
    if path == '':
        return None
    head, tail = os.path.split(path)
    name, ex = os.path.splitext(path)
    if ex not in types.keys():
        return None
    file_type = types[ex]
    project_path = get_project_dir(path)
    io = om.MFileIO()
    if cmds.file(q=1, sceneName=True) == '':
        new_open()
    else:
        result = cmds.confirmDialog(t='File Open',
                                    m='New Scene Open or Import Scene?',
                                    b=['New Scene', 'Import Scene', 'Cancel'],
                                    db='New Scene',
                                    cb='Cancel',
                                    ds='Cancel')
        if result == 'Cancel':
            return None
        elif result == 'New Scene':
            new_open()
        elif result == 'Import Scene':
            fbx_plugin = 'fbxmaya'
            cmds.loadPlugin('{0:}.mll'.format(fbx_plugin), qt=1)
            if fbx_plugin not in cmds.pluginInfo(q=1, ls=1):
                om.MGlobal.displayError(
                    '{0} Plugin in not loaded'.format(fbx_plugin))
                return None
            io.importFile(path, file_type, 1, str(tail.replace('.', '_')))

    # テクスチャのリロード
    #ls = cmds.ls(typ='file', type='mentalrayTexture')
    #[cmds.setAttr(x + '.ftn', cmds.getAttr(x + '.ftn'), type='string') for x in ls]
    return 0
Пример #4
0
 def openFile(self, maya_file):
     if maya_file:
         mFile = OpenMaya.MFileIO()
         mFile.open(r"%s" % os.path.abspath(maya_file).replace("\\", "/"),
                    None, True)
Пример #5
0
 def openFile(self):
     maya_file = self.filepath_label.text()
     if maya_file:
         mFile = OpenMaya.MFileIO()
         mFile.open(r"%s" % os.path.abspath(maya_file).replace("\\", "/"),
                    None, True)
Пример #6
0
def save_file(source_file, stamped_time):
    file_io = OpenMaya.MFileIO()
    # file_io.open(source_file)
    file_type = file_io.fileType()
    file_io.saveAs(source_file, file_type.encode(), True)
    os.utime(source_file, (stamped_time, stamped_time))