def exportCurrentFrame(self): exportPath = mh.getPath('exports') if not os.path.exists(exportPath): os.makedirs(exportPath) mh2obj.exportObj(gui3d.app.selectedHuman.meshData, os.path.join(exportPath, 'bvh_frame_%d.obj' % self.frameSlider.getValue()))
def quickExport(self): exportPath = mh.getPath('exports') if not os.path.exists(exportPath): os.makedirs(exportPath) import mh2obj mh2obj.exportObj(self.selectedHuman.meshData, exportPath + '/quick_export.obj') import mh2bvh mh2bvh.exportSkeleton(self.selectedHuman.meshData, exportPath + '/quick_export.bvh') import mh2mhx mh2mhx.exportMhx(self.selectedHuman.meshData, exportPath + '/quick_export.mhx')
def onClicked(event): exportObj(gui3d.app.selectedHuman.meshData, os.path.join(mh.getPath('exports'), "posed.obj"))
def onFileSelected(filename): exportPath = mh.getPath('exports') if not os.path.exists(exportPath): os.makedirs(exportPath) if self.wavefrontObj.selected: if self.exportEyebrows.selected and self.exportDiamonds.selected: filter = None elif self.exportEyebrows.selected: filter = lambda fg: not ('joint' in fg.name or 'helper' in fg.name) elif self.exportDiamonds.selected: filter = lambda fg: not 'eyebrown' in fg.name else: filter = lambda fg: not ('joint' in fg.name or 'helper' in fg.name or 'eyebrown' in fg.name) human = gui3d.app.selectedHuman mesh = human.getSubdivisionMesh() if self.exportSmooth.selected else human.getSeedMesh() mh2obj.exportObj(mesh, os.path.join(exportPath, filename + ".obj"), self.exportGroups.selected, filter) options = { "helpers" : self.exportDiamonds.selected, "eyebrows" : self.exportEyebrows.selected, "lashes" : self.exportLashes.selected, "scale": self.getScale(self.objScales), "pngTexture": True, #self.exportPngTexture.selected } mh2obj_proxy.exportProxyObj(gui3d.app.selectedHuman, os.path.join(exportPath, filename), options) if self.exportSkeleton.selected: mh2bvh.exportSkeleton(human.meshData, os.path.join(exportPath, filename + ".bvh")) if self.exportHair.selected and human.hairObj and human.hairObj.mesh and human.hairObj.mesh.verts: mesh = human.hairObj.getSubdivisionMesh() if self.exportSmooth.selected else human.hairObj.getSeedMesh() mh2obj.exportObj(mesh, os.path.join(exportPath, "hair_" + filename+".obj")) texturePath = os.path.join(exportPath, basename(mesh.texture)) if not os.path.isfile(texturePath): copyfile(mesh.texture, texturePath) texturePath = os.path.join(exportPath, basename(mesh.texture)) if not os.path.isfile(texturePath): copyfile(mesh.texture, texturePath) elif self.mhx.selected: if self.mhxConfig.selected: options = None else: mhxversion = [] if self.version24.selected: mhxversion.append('24') if self.version25.selected: mhxversion.append('25') for (button, rig) in self.mhxRigs: if button.selected: break options = { 'mhxversion':mhxversion, 'expressions':False, #self.exportExpressions.selected, 'expressionunits':self.exportExpressionUnits.selected, 'faceshapes':self.exportFaceShapes.selected, 'bodyshapes':self.exportBodyShapes.selected, 'facepanel':self.exportFacePanel.selected, 'clothes':self.exportClothes.selected, 'cage':self.exportCage.selected, 'separatefolder':self.exportSeparateFolder.selected, 'feetonground':self.exportFeetOnGround.selected, 'advancedspine':self.exportAdvancedSpine.selected, 'malerig':self.exportMaleRig.selected, 'skirtrig':False, #self.exportSkirtRig.selected, 'clothesrig':self.exportClothesRig.selected, 'mhxrig': rig, } mh2mhx.exportMhx(gui3d.app.selectedHuman, os.path.join(exportPath, filename + ".mhx"), options) elif self.collada.selected: for (button, rig) in self.daeRigs: if button.selected: break options = { "daerig": rig, "rotate90X" : self.colladaRot90X.selected, "rotate90Z" : self.colladaRot90Z.selected, "eyebrows" : self.colladaEyebrows.selected, "lashes" : self.colladaLashes.selected, "helpers" : self.colladaHelpers.selected, "scale": self.getScale(self.daeScales), "pngTexture": True, #self.colladaPngTexture.selected } mh2collada.exportCollada(gui3d.app.selectedHuman, os.path.join(exportPath, filename), options) elif self.md5.selected: mh2md5.exportMd5(gui3d.app.selectedHuman.meshData, os.path.join(exportPath, filename + ".md5mesh")) elif self.stl.selected: mesh = gui3d.app.selectedHuman.getSubdivisionMesh() if self.exportSmooth.selected else gui3d.app.selectedHuman.meshData if self.stlAscii.selected: mh2stl.exportStlAscii(mesh, os.path.join(exportPath, filename + ".stl")) else: mh2stl.exportStlBinary(mesh, os.path.join(exportPath, filename + ".stl")) elif self.skel.selected: mesh = gui3d.app.selectedHuman.getSubdivisionMesh() if self.exportSmooth.selected else gui3d.app.selectedHuman.meshData mh2skel.exportSkel(mesh, os.path.join(exportPath, filename + ".skel")) gui3d.app.prompt('Info', u'The mesh has been exported to %s.' % os.path.join(mh.getPath(''), u'exports'), 'OK', helpId='exportHelp') gui3d.app.switchCategory('Modelling')
if key == '': continue if not modDict.has_key(key): raise SyntaxError("There is no modifier: " + key) else: mod = modDict[key] val *= mod.getMax() - mod.getMin() val += mod.getMin() modDict[key].setValue(val) buddy.applyAllTargets() #Put proxy objects in the right place buddyProxy.update(mesh, False) mesh.update() obj.setSubdivided(buddy.isSubdivided()) name = 'default' if params.has_key('name'): name = params['name'] if not os.path.exists("../models"): os.makedirs("../models") sys.stdout = stdout mh2obj.exportObj("../models/" + name + ".obj", conf) #application.run() #import cProfile #cProfile.run('application.run()') close_standard_streams()