예제 #1
0
    def copyTextureToNewLocation(self, filepath):
        import os
        import shutil
        import getpath

        srcDir = os.path.abspath(os.path.expanduser(os.path.dirname(filepath)))
        filename = os.path.basename(filepath)

        newpath = os.path.abspath(os.path.join(self.texFolder, filename))
        try:
            self._copiedFiles[filepath]
            done = True
        except:
            done = False
        if not done:
            try:
                shutil.copyfile(filepath, newpath)
            except:
                log.message("Unable to copy \"%s\" -> \"%s\"" %
                            (filepath, newpath))
            self._copiedFiles[filepath] = True

        if not self.useRelPaths:
            return getpath.formatPath(newpath)
        else:
            relpath = os.path.relpath(newpath, self.outFolder)
            return getpath.formatPath(relpath)
예제 #2
0
def saveMHM(path):
    """Save the .mhm and the thumbnail to the selected save path."""
    path = pathToUnicode(os.path.normpath(path))

    savedir = os.path.dirname(path)
    if not os.path.exists(savedir):
        os.makedirs(savedir)

    name = os.path.splitext(os.path.basename(path))[0]

    # Save square sized thumbnail
    size = min(G.windowWidth, G.windowHeight)
    img = mh.grabScreen((G.windowWidth - size) // 2,
                        (G.windowHeight - size) // 2, size, size)

    # Resize thumbnail to max 128x128
    if size > 128:
        img.resize(128, 128)
    img.save(os.path.join(savedir, name + '.thumb'))

    # Save the model
    G.app.selectedHuman.save(path)
    #G.app.clearUndoRedo()

    # Remember last save folder
    gui3d.app.setSetting('savedir', formatPath(os.path.dirname(path)))

    G.app.status('Your model has been saved to %s.', path)
예제 #3
0
def _getFilePath(filename, folder = None, altExtensions=None):
    import getpath
    if altExtensions is not None:
        # Search for existing path with alternative file extension
        for aExt in altExtensions:
            if aExt.startswith('.'):
                aExt = aExt[1:]
            aFile = os.path.splitext(filename)[0]+'.'+aExt
            aPath = _getFilePath(aFile, folder, altExtensions=None)
            if os.path.isfile(aPath):
                # Path found, return result with original extension
                orgExt = os.path.splitext(filename)[1]
                path = os.path.splitext(aPath)[0]+orgExt
                return getpath.formatPath(path)

    if not filename or not isinstance(filename, basestring):
        return filename

    searchPaths = []

    # Search within current folder
    if folder:
        searchPaths.append(folder)

    return getpath.thoroughFindFile(filename, searchPaths)
예제 #4
0
        def onFileSelected(event):
            dir, name = os.path.split(event.path)
            name, ext = os.path.splitext(name)

            if not os.path.exists(dir):
                os.makedirs(dir)

            # Remember last used export folder
            gui3d.app.setSetting('exportdir', formatPath(dir))

            def filename(targetExt, different=False):
                if not different and ext != '' and (
                        '.' + targetExt.lower()) != ext.lower():
                    log.warning("expected extension '.%s' but got '%s'",
                                targetExt, ext)
                return os.path.join(dir, name + '.' + targetExt)

            for exporter in [f[0] for f in self.formats if f[1].selected]:
                if self.showOverwriteWarning and \
                    event.source in ('button', 'return') and \
                    os.path.exists(os.path.join(dir, name + '.' + exporter.fileExtension)):
                    if not gui3d.app.prompt(
                            "File exists",
                            "The file already exists. Overwrite?", "Yes",
                            "No"):
                        break
                exporter.export(gui3d.app.selectedHuman, filename)
                gui3d.app.status(['The mesh has been exported to', ' %s.'],
                                 dir)
                self.showOverwriteWarning = False
                break
            else:
                log.error("Unknown export format selected!")
예제 #5
0
def _getFilePath(filename, folder=None, altExtensions=None):
    import getpath
    if altExtensions is not None:
        # Search for existing path with alternative file extension
        for aExt in altExtensions:
            if aExt.startswith('.'):
                aExt = aExt[1:]
            aFile = os.path.splitext(filename)[0] + '.' + aExt
            aPath = _getFilePath(aFile, folder, altExtensions=None)
            if os.path.isfile(aPath):
                # Path found, return result with original extension
                orgExt = os.path.splitext(filename)[1]
                path = os.path.splitext(aPath)[0] + orgExt
                return getpath.formatPath(path)

    if not filename or not isinstance(filename, basestring):
        return filename

    searchPaths = []

    # Search within current folder
    if folder:
        searchPaths.append(folder)

    return getpath.thoroughFindFile(filename, searchPaths)
예제 #6
0
파일: proxy.py 프로젝트: kingomyths/mhx_os
    def getActualTexture(self, human):
        uuid = self.getUuid()
        mesh = None

        if human.proxy and uuid == human.proxy.uuid:
            mesh = human.mesh
        else:
            for pxy in human.getProxies():
                if pxy and uuid == pxy.uuid:
                    mesh = pxy.object.mesh
                    break

        return getpath.formatPath(mesh.texture)
예제 #7
0
 def onClicked(event):
     if hasConfigFile():
         os.remove(getConfigPath('makehuman.conf'))
         self.homeButton.setLabel('Create Config File')
         gui3d.app.statusPersist('Home Folder Location: Default')
     else:
         filePath = getConfigPath('makehuman.conf')
         homePath = formatPath(getExistingDirectory(getHomePath()))
         if homePath != '.':
             if sys.platform.startswith('darwin') or sys.platform.startswith('linux') and not os.path.isdir(getConfigPath('')):
                 os.makedirs(getConfigPath(''))
             if os.path.isdir(homePath) and os.path.isdir(getConfigPath('')):
                 with io.open(filePath, 'w', encoding='utf-8') as f:
                     f.writelines(homePath + '\n')
             self.homeButton.setLabel('Delete Config File')
             gui3d.app.statusPersist('Home Folder Location: ' + homePath)
예제 #8
0
 def onFileSelected(event):
     self.filechooser.setPaths([event.path])
     self.filechooser.refresh()
     # Remember load folder
     gui3d.app.setSetting('loaddir', formatPath(event.path))