def gen_pick_img(path, force, crop, auto_id, skip_lights, skip_shaders): img_path = "C:/work/ids/{0}.exr".format(FileSystem.name(path)) exr_path = img_path.replace(".exr", ".objectId.exr") rgb_path = img_path.replace(".exr", "_rgb.png") ids_path = img_path.replace(".exr", "_ids.png") id_cache = img_path.replace(".exr", "_nodes.json") # reuse cached results if (not force) and FileSystem.valid(img_path): jconf = JsonConfig(id_cache) return exr_path, rgb_path, ids_path, dict(jconf) # render and extract existing ids from cgev.vray import sdk from cgev.vray import VRayScene sdk.enableFrameBuffer = True r = VRayScene(path, renderMode="production") token = r.renderIdPass(path=img_path, auto_id=auto_id, crop=crop, skip_lights=skip_lights, skip_shaders=skip_shaders) r.release() # cache ids mapping jconf = JsonConfig(token[3]) jconf.save(id_cache) return token
def countFolder(path): path = os.path.join(environment.getGitPath(), path) files = FileSystem.find(path, '^.*\.py$') counts = dict() count = 0 for file in files: base = os.path.basename(file) base = os.path.splitext(base)[0] if base in avoid: continue counts[base] = countFile(file) count += counts[base] print "... {0} -> {1}".format(count, path) print "" files = counts.keys() files.sort() for file in files: print "{0} : {1}".format(file, counts[file]) print "" return count
def writeWrapScript(py_path, name, args): path = FileSystem.njoin(os.path.dirname(py_path), name + "_wrap.py") script = """ import scramble from hello import main """ script += "\nargs = " + repr(args) script += """ if __name__ == "__main__": main(args) """ with open(path, "w") as f: f.write(script) print script print os.path.exists(path) return path
def runProcs(self): log.info("Detach processes ...") p = list() p.append("C:\\work\\scenes\\vray\\test\\cubes.vrscene") p.append("C:\\work\\scenes\\vray\\test\\sphere.vrscene") for i in range(self.numTest): for path in p: name = FileSystem.name(path) + '_' + str(i) self.detach(name, path)
def batchSceneExport(py_path, scene, out_path): name = FileSystem.name(scene) options = dict() tgt_path = "//stora/diska/tmp/aprevot/hello/test.vrscene" options["ImageFileName"] = FileSystem.name(tgt_path) + "." options["ImageDir"] = os.path.dirname(tgt_path) options["ImageExtension"] = "vrscene" options["SceneName"] = scene options["Layer"] = "VRScene" # options["ImageFileName"] = FileSystem.name(py_path) + "." # options["imageDir"] = os.path.dirname(py_path) # options["ImageExtension"] = "py" args = dict() args["scene"] = scene args["out_path"] = out_path wrap_script = writeWrapScript(py_path, FileSystem.name(scene), args) return batchMayaPy(wrap_script, options)
def parseFolder(path): label = path.split("/cgev/")[1] label = "cgev." + label.replace("/", ".") path = os.path.join(environment.getGitPath(), path) files = FileSystem.find(path, "^.*\.py$") print label for file in files: base = os.path.basename(file) if base in avoid: continue parseFile(os.path.join(path, base))
self.show() if __name__ == "__main__": # path = "C:/work/scenes/vray/test/multi_sphere.vrscene" # path = "C:/work/scenes/vray/test/stalingrad.vrscene" path = "C:/work/scenes/vray/test/halifax.vrscene" force = False auto_id = False skip_lights = False skip_shaders = False crop = False for arg in sys.argv[1:]: if FileSystem.isPath(arg): path = arg elif arg in ["--force", "-f"]: force = True elif arg in ["--auto", "-a"]: auto_id = True elif arg in ["--lights", "-l"]: skip_lights = True elif arg in ["--shaders", "-s"]: skip_shaders = True elif arg in ["--crop", "-c"]: crop = [640, 480] if not FileSystem.valid(path): dbg("ERROR : invalid scene {0}", path) sys.exit(1)
def test_folder(path): print "..." print path print FileSystem.validUnc(path)