Octane - Modo Batch Rendering Script

Forums: Octane - Modo Batch Rendering Script
Foundry Modo (Developed by stenson, Integrated Plugin developed by Paul Kinnane)

Moderator: face_off

Octane - Modo Batch Rendering Script

Postby LFedit » Mon Nov 23, 2020 11:05 pm

LFedit Mon Nov 23, 2020 11:05 pm
Hey everyone,

So I am jumping into scripting. I want to create a script for batch rendering. I am new to this... But I have watched a few videos on it now. I am stuck. I can get it to open the octane viewport and render and saves the file. Yay go me.

I am using the octane save animation command so it automatically uses my settings I have set and saves to that location set. (I plan on setting this manually the better I get with the octane save command and this question might enable that too)

But how to I get it to close the viewport after it reaches max samples or do anything after it reaches max samples? I tried looking into how it switched after it finished a frame (because it obviously reached max samples before it switched) but couldn't find anything.

I was trying some types of if statements but kept getting errors..


Thats what I have now, but I get an error because I know its trying to quit the app (I had close scene before too) before it hits the max samples... If I can get it to reach max samples before moving on, it would solve a few headaches for me.


lx.eval("octane.openViewport")

lx.eval("octane.command animate")

lx.eval("app.quit")

I am by no means trying to make something to sell or distribute. Just a down and dirty script for me to queue a bunch of stills or animations if I tweak the code.

Thanks!
Last edited by LFedit on Wed Nov 25, 2020 4:06 pm, edited 1 time in total.
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Scripting question

Postby LFedit » Tue Nov 24, 2020 4:06 pm

LFedit Tue Nov 24, 2020 4:06 pm
It keeps failing when I bring in lines like this from the commands

lx.eval(octane.renderAndSave png8 "C:\Users\-----\Desktop\testing\untitled")

I am guessing I am formatting that wrong... I read somewhere if you put lx.eval in front of whatever the command was it should work. But I am guessing that isn't the case for octane. But it did work with the lx.eval("octane.openViewport")

and lx.eval("octane.command animate") commands.

Edit - I have everything running exactly how I want, but its just still not saving the actual file... Here is the line of code for rendering and savings

lx.eval("octane.renderAndSave png8 {C:\Users\-----\Desktop\testing\untitled.png}") What am I doing wrong?!

Is there anymore documentation on this process at all by any chance? Like Modo-Octane coding? I know that's pretty specific..
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Scripting question

Postby LFedit » Tue Nov 24, 2020 9:59 pm

LFedit Tue Nov 24, 2020 9:59 pm
GOT IT. The \ had to get switched to /. I will leave this thread up for future reference for others, and probably myself...
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Scripting question

Postby face_off » Wed Nov 25, 2020 12:41 am

face_off Wed Nov 25, 2020 12:41 am
Sorry for the late reply. It would be great it you could share some of your code once done, as it might be useful to others.

Thanks

Paul
Win7/Win10/Mavericks/Mint 17 - GTX550Ti/GT640M
Octane Plugin Support : Poser, ArchiCAD, Revit, Inventor, AutoCAD, Rhino, Modo, Nuke
Pls read before submitting a support question
User avatar
face_off
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15473
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: Scripting question

Postby LFedit » Wed Nov 25, 2020 3:35 pm

LFedit Wed Nov 25, 2020 3:35 pm
Its really down and dirty right now but it works. VERY MINIMAL TESTING TOO. So don't go crazy on me if something breaks. I am going to work on making it easier to setup too but for now, it will work in a pinch. There's your disclaimer.

Also, be sure to open a fresh scene of modo with the octane viewport closed, otherwise you will get an error.

in the #Opens the scene line, you need to set the name of the project file and

lx.eval("scene.open {C:/Users/-----/Desktop/Temp/cbe.lxo} normal") <--- Change that to your first project file. IF YOU COPY AND PASTE FROM WINDOWS EXPLORER BE SURE TO CHANGE THE "\"'s to "/"s.


#Renders current scene be sure to change the file type here "png8" to whatever you want it to be. Then also where you want to write the file to and file name. Once again change the \ to /.


lx.eval("octane.renderAndSave png8 {C:/Users/-----/Desktop/testing/untitled.png}")


Then just copy and paste for more and more scenes. BUTTTTT in the second section of code, be sure to not include the code -

#Opens Octane Render Viewport
lx.eval("octane.openViewport")

Because the viewport will already be open. So when you copy and paste either take that out, or just use what I have because its already out.


And thats it, its pretty simple, especially if you save as the scenes to a single location, then you can easily copy and paste the scene locations.

Like I said, I haven't done much testing. But it uses mostly octane commands that are preset and work well.

My next step is to include animation into the code.

And my disclaimer again - I am no means a coder by any stretch of the imagination, this is my first script and it actually solves a very large problem for me, so I will hopefully stick with it and make this better.

Also, another thing that I found great is, this is opening in the background and a progress bar pops up for the rendering status in samples. I am sure Paul knows why this is, but its super awesome, because it doesn't take time to open the scene. I have no idea how that works though, but its awesome :).

Next step is to include a line of code for animations to work in tandem with stills. I will report when I finish it, ha, IF I finish it without pulling my hair out.

Enjoy! :)


HERES THE FINAL CODE TO ADD MORE COPY AND PASTE THE SECOND BLOCK OF CODE!



#Batch Rendering Script
#Opens the scene
lx.eval("scene.open {C:/Users/-----/Desktop/Temp/cbe.lxo} normal")
#Opens Octane Render Viewport
lx.eval("octane.openViewport")
#Renders current scene
lx.eval("octane.renderAndSave png8 {C:/Users/-----/Desktop/testing/untitled.png}")
#Close current scene
lx.eval("scene.close")


#Next Render

#Opens next scene
lx.eval("scene.open {C:/Users/----/Desktop/Temp/longer.lxo} normal")
#Renders - Viewport is already open from first render.
lx.eval("octane.renderAndSave png8 {C:/Users/----/Desktop/testing/longer.png}")
#Closes Current Scene
lx.eval("scene.close")
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Octane - Modo Batch Rendering Script

Postby LFedit » Wed Nov 25, 2020 5:07 pm

LFedit Wed Nov 25, 2020 5:07 pm
Hey Paul so I have this simple code for animations, but it keeps wanting to close before the animation is done. Which makes sense. Any idea on how I can have it wait until the animation is completel before it tries to close the scene. Then it should be easy to implement into having stills and animations in the same script.


#Opens next scene
lx.eval("scene.open {C:/Users/-----/Desktop/Temp/longeranimated.lxo} normal")
#Renders - Viewport is already open from first render.
lx.eval("octane.command animate")
#Closes Current Scene
lx.eval("scene.close")
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Octane - Modo Batch Rendering Script

Postby face_off » Thu Nov 26, 2020 5:55 am

face_off Thu Nov 26, 2020 5:55 am
LFedit wrote:Hey Paul so I have this simple code for animations, but it keeps wanting to close before the animation is done. Which makes sense. Any idea on how I can have it wait until the animation is completel before it tries to close the scene. Then it should be easy to implement into having stills and animations in the same script.


#Opens next scene
lx.eval("scene.open {C:/Users/-----/Desktop/Temp/longeranimated.lxo} normal")
#Renders - Viewport is already open from first render.
lx.eval("octane.command animate")
#Closes Current Scene
lx.eval("scene.close")
I am midway through trying to get the plugin working with Octane 2020.2, so cannot run it at the moment, but you could try something like the following to close the viewport:

Code: Select all
layout.createOrClose octaneRenderViewportFrameCookie octaneViewportLayout title:{OctaneRender Viewport} persistent:true style:standard width:600 height:40


You may not need the "title..." onwards text.

Paul
Win7/Win10/Mavericks/Mint 17 - GTX550Ti/GT640M
Octane Plugin Support : Poser, ArchiCAD, Revit, Inventor, AutoCAD, Rhino, Modo, Nuke
Pls read before submitting a support question
User avatar
face_off
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15473
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: Octane - Modo Batch Rendering Script

Postby LFedit » Sat Nov 28, 2020 10:54 pm

LFedit Sat Nov 28, 2020 10:54 pm
Thanks Paul, no worries. Its not a big deal for me to keep the viewport open. My problem is the scene close command is running right away when I run the animate command, instead of waiting for the render to finish. The stills command renders and doesn't move on to close scene until its done rendering and saved. But the octane animate command is letting the close scene command run right away. I need some way to make it wait until the entire animation is complete before it runs the close scene command.

Thanks!
Win 7 64bit/ Nvidia Maximus k5000 and k20
LFedit
Licensed Customer
Licensed Customer
 
Posts: 408
Joined: Tue Jan 22, 2013 12:00 am

Re: Octane - Modo Batch Rendering Script

Postby face_off » Sun Nov 29, 2020 10:11 am

face_off Sun Nov 29, 2020 10:11 am
LFedit wrote:Thanks Paul, no worries. Its not a big deal for me to keep the viewport open. My problem is the scene close command is running right away when I run the animate command, instead of waiting for the render to finish. The stills command renders and doesn't move on to close scene until its done rendering and saved. But the octane animate command is letting the close scene command run right away. I need some way to make it wait until the entire animation is complete before it runs the close scene command.

Thanks!
Yes - the python script does not get blocked by the 'octane.command animate' command, so terminates with the scene close. I think the way around this is check the current Modo frame every second, and once it is the last frame, you know the animation is complete.

Paul
Win7/Win10/Mavericks/Mint 17 - GTX550Ti/GT640M
Octane Plugin Support : Poser, ArchiCAD, Revit, Inventor, AutoCAD, Rhino, Modo, Nuke
Pls read before submitting a support question
User avatar
face_off
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 15473
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: Octane - Modo Batch Rendering Script

Postby Hesekiel2517 » Tue Feb 09, 2021 7:10 am

Hesekiel2517 Tue Feb 09, 2021 7:10 am
I don't know if that helps, but "Render Monkey" is open source https://github.com/9bstudios/mecco_renderMonkey maybe this is a great foundation for a octane Batch render utility.
Hesekiel2517
Licensed Customer
Licensed Customer
 
Posts: 450
Joined: Mon Nov 23, 2015 10:57 pm
Next

Return to Foundry Modo


Who is online

Users browsing this forum: No registered users and 7 guests

Tue Apr 16, 2024 9:50 pm [ UTC ]