LaidlawFX Posted August 16, 2013 Share Posted August 16, 2013 (edited) Trying to make a post-render script on a bgeo rop that when I write a .bhclassic it will rename it to .bgeo, and then I can have vray convert the h11 .bgeo into a vrmesh. The post rename should be easy, but yeah... I stink at python, or the doing python in the post-render script has some weird syntax. I have switched the drop down to python. I am on windows, so not sure if that is throwing me off. import globimport osfor filename in glob.iglob(os.path.join(hou.expandString('`chs("../HscriptDirectoryPath")`'), '*.bhclassic')):os.rename(filename, filename[:-9] + '.bgeo')[/CODE]I would like to figure the vrmesh conversion on my own, but if some one know that easily, I would be happy to push off my python learning for the short term once more.Thanks for the help.....One sec may not be a complete python noob, with the first part, of course it worked in the simple test scene I was about to post... guessing it a stupid slash thing Edited August 16, 2013 by LaidlawFX Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted August 16, 2013 Share Posted August 16, 2013 (edited) to fix slashes use import osfilesPath = os.path.join(hou.expandString('`chs("../HscriptDirectoryPath")`'), '*.bhclassic')fixedPath = os.path.normpath(filesPath)[/CODE] Edited August 16, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted August 16, 2013 Share Posted August 16, 2013 (edited) You mean this vrmesh? I do hope you don't need it for today? EDIT: Beside, instead of this filename[:-9] + '.bgeo' use "{0}.{1}".format(filename.split('.')[0], "bgeo") to change extension in filename Edited August 17, 2013 by mantragora Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted August 16, 2013 Author Share Posted August 16, 2013 So this is what I got with some help here... it seems to work... need to clear out the old files now and hope it works at render time import globimport osimport subprocessconverterPath = r"C:\Path\To\ply2vrmesh.exe"for filename in glob.iglob(os.path.join(hou.expandString('`chs("dir")`'), '*.bhclassic')): filename = os.path.normpath(filename) #print filename newfilename = filename[:-10] + '.bgeo' #print newfilename os.rename(filename, newfilename) p = subprocess.Popen([converterPath, "-smoothNormals", "-flipYPosZ", newfilename]) p.wait()[/CODE] Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted August 17, 2013 Share Posted August 17, 2013 Works? Remember that if you want to run a file from Post-Render Script field on Mantra, you need to use execfile(yourScriptPath) This field expects code not a path so putting just a path to file will return error. Remember to expandString if the path is from variable Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted August 17, 2013 Author Share Posted August 17, 2013 Ah ok, that explains why we ran into the error with the converterPath being inside It creates the vrmeshes, but apparently you can not have multiple wait() commands to then remove the temporary .bgeo file. which would be the next step. :\ p = subprocess.Popen([converterPath, "-smoothNormals", "-flipYPosZ", newfilename]) p.wait() w = os.remove(filename) w.wait()[/CODE] Quote Link to comment Share on other sites More sharing options...
LaidlawFX Posted August 17, 2013 Author Share Posted August 17, 2013 (edited) I'm soo glad there are people smarter than me.... lol.... copy and paste the for loop to just do the remove, lol, soo simple import globimport osimport subprocessconverterPath = r[color=#008800][size=2][background=rgb(248, 248, 248)]"C:\Path\To\ply2vrmesh.exe"[/background][/size][/color]for filename in glob.iglob(os.path.join(hou.expandString('`chs("dir")`'), '*.bhclassic')):filename = os.path.normpath(filename)# print filenamenewfilename = filename[:-10] + '.bgeo'# print newfilenameos.rename(filename, newfilename)p = subprocess.Popen([converterPath, "-smoothNormals", "-flipYPosZ", newfilename])p.wait()for filename in glob.iglob(os.path.join(hou.expandString('`chs("dir")`'), '*.bgeo')):os.remove(filename)[/CODE]Thanks again mantragora Edited August 17, 2013 by LaidlawFX Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.