def binMeshTranslatorWrite(fileName, optionString, accessMode): exportPath = fileName createProxies = False proxyRes = 0.1 all = False oneFilePerMesh = False useTransform = False # the very first sign is a ; so the first element cannot be split again, no idea why opts = optionString.split(";") for opt in opts: try: name, value = opt.split("=") if name == "oneFilePerMesh": oneFilePerMesh = int(value) if name == "createProxies": createProxies = int(value) if name == "useTransform": useTransform = int(value) if name == "proxyRes": proxyRes = float(proxyRes) except: pass if accessMode == "selected": selection = [] for object in pm.ls(sl=True): selection.extend(object.getChildren(ad=True, type="mesh")) if len(selection) == 0: raise pm.binMeshWriterCmd(selection, path=exportPath, doProxy=createProxies, percentage=proxyRes, doTransform=useTransform, oneFilePerMesh=oneFilePerMesh) if accessMode == "all": pm.binMeshWriterCmd(path=exportPath, doProxy=createProxies, percentage=proxyRes, doTransform=useTransform, all=True, oneFilePerMesh=oneFilePerMesh) return True
def perform(self, *args): selection = [] for object in pm.ls(sl=True): selection.extend(object.getChildren(ad=True, type="mesh")) if len(selection) == 0: log.error("Export standins: No meshes selected.") return path = pm.optionVar.get('mtap_binMeshExportPath', pm.workspace.path + "/geo/export.binarymesh") prefix = pm.optionVar.get('mtap_binMeshExportPathPrefix', "prefix") doProxy = pm.optionVar.get('mtap_binMeshCreateProxy', True) percentage = pm.optionVar.get('mtap_binMeshPercentage', 0.1) createStandin = pm.optionVar.get('mtap_binMeshCreateStandin', True) oneFilePerMesh = pm.optionVar.get('mtap_binMeshOneFilePerMesh', False) useTransform = pm.optionVar.get('mtap_binMeshUseTransform', False) if not os.path.exists(path): os.makedirs(path) bpath = path + "/" + prefix + ".binarymesh" #TODO: convert namespace to clean name print "pm.binMeshWriterCmd({0}, doProxy = {1}, path={2}, doTransform = {3}, percentage={4}, oneFilePerMesh={5})".format( selection, doProxy, bpath, useTransform, percentage, oneFilePerMesh) pm.binMeshWriterCmd(selection, doProxy=doProxy, path=bpath, doTransform=useTransform, percentage=percentage, oneFilePerMesh=oneFilePerMesh) if not doProxy: log.debug("No proxy creation.") return # we we write multiple meshes into one file, we should create one standin mesh only if not oneFilePerMesh and len(selection) > 1: selection = [bpath] for mesh in selection: meshName = mesh.split("/")[-1].replace(".binarymesh", "") print "creating stdin node for mesh", meshName standInMesh = pm.createNode("mesh") standInMesh.getParent().rename(meshName + "_standIn") standInMeshNode = pm.createNode("mtap_standinMeshNode") standInMeshNode.rename(meshName + "_standInCreator") bpath = path + "/" + prefix + meshName + ".binarymesh" print "Setting binmesh path to", bpath standInMeshNode.binMeshFile.set(bpath) standInMeshNode.outputMesh >> standInMesh.inMesh self.cancel()
def binMeshTranslatorWrite(fileName, optionString, accessMode): exportPath = fileName createProxies = False proxyRes = 0.1 all = False oneFilePerMesh = False useTransform = False #print "OptionString", optionString # the very first sign is a ; so the first element cannot be split again, no idea why opts = optionString.split(";") for opt in opts: print "Opt", opt try: name, value = opt.split("=") if name == "oneFilePerMesh": oneFilePerMesh = int(value) if name == "createProxies": createProxies = int(value) if name == "useTransform": useTransform = int(value) if name == "proxyRes": proxyRes = float(proxyRes) except: pass if accessMode == "selected": print "binMeshTranslatorWrite selected" selection = [] for object in pm.ls(sl=True): selection.extend(object.getChildren(ad=True, type="mesh")) if len(selection) == 0: print "Fehler: No mesh objects found in selection." raise pm.binMeshWriterCmd(selection, path=exportPath, doProxy=createProxies, percentage=proxyRes, doTransform=useTransform, oneFilePerMesh=oneFilePerMesh) if accessMode == "all": print "binMeshTranslatorWrite all" pm.binMeshWriterCmd(path=exportPath, doProxy=createProxies, percentage=proxyRes, doTransform=useTransform, all=True, oneFilePerMesh=oneFilePerMesh) return True
def perform(self, *args): selection = [] for object in pm.ls(sl=True): selection.extend(object.getChildren(ad=True, type="mesh")) if len(selection) == 0: log.error("Export standins: No meshes selected.") return path = pm.optionVar.get('mtap_binMeshExportPath', pm.workspace.path + "/geo/export.binarymesh") prefix = pm.optionVar.get('mtap_binMeshExportPathPrefix', "prefix") doProxy = pm.optionVar.get('mtap_binMeshCreateProxy', True) percentage = pm.optionVar.get('mtap_binMeshPercentage', 0.1) createStandin = pm.optionVar.get('mtap_binMeshCreateStandin', True) oneFilePerMesh = pm.optionVar.get('mtap_binMeshOneFilePerMesh', False) useTransform = pm.optionVar.get('mtap_binMeshUseTransform', False) if not os.path.exists(path): os.makedirs(path) bpath = path + "/" + prefix + ".binarymesh" #TODO: convert namespace to clean name print "pm.binMeshWriterCmd({0}, doProxy = {1}, path={2}, doTransform = {3}, percentage={4}, oneFilePerMesh={5})".format(selection, doProxy, bpath, useTransform, percentage, oneFilePerMesh) pm.binMeshWriterCmd(selection, doProxy = doProxy, path=bpath, doTransform = useTransform, percentage=percentage, oneFilePerMesh=oneFilePerMesh) if not doProxy: log.debug("No proxy creation.") return # we we write multiple meshes into one file, we should create one standin mesh only if not oneFilePerMesh and len(selection) > 1: selection = [bpath] for mesh in selection: meshName = mesh.split("/")[-1].replace(".binarymesh", "") print "creating stdin node for mesh", meshName standInMesh = pm.createNode("mesh") standInMesh.getParent().rename(meshName + "_standIn") standInMeshNode = pm.createNode("mtap_standinMeshNode") standInMeshNode.rename(meshName + "_standInCreator") bpath = path + "/" + prefix + meshName + ".binarymesh" print "Setting binmesh path to", bpath standInMeshNode.binMeshFile.set(bpath) standInMeshNode.outputMesh >> standInMesh.inMesh self.cancel()