OctaneRender for Modo SCRIPTS

Forums: OctaneRender for Modo SCRIPTS
Foundry Modo (Developed by stenson, Integrated Plugin developed by Paul Kinnane)

Moderator: face_off

OctaneRender for Modo SCRIPTS

Postby face_off » Fri Nov 19, 2021 1:33 am

face_off Fri Nov 19, 2021 1:33 am
Hi

This thread if for discussion and assistance of Modo scripts that interface/interact with the plugin.

Post here if you would like to share a script you have written, if you would like to request a specific script be written, or if you need help with a script you are writing.

I am sure there are expert Modo python users here, so it would be great to have their input (as I am a C++ guy!). Over time we can get a library of scripts that the community can share, use, and modify for their own needs.

Shortcuts....


Thanks

Paul
Last edited by face_off on Thu Dec 28, 2023 6:46 am, edited 7 times in total.
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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: OctaneRender for Modo SCRIPTS

Postby Hesekiel2517 » Mon Nov 22, 2021 11:58 am

Hesekiel2517 Mon Nov 22, 2021 11:58 am
Hey Paul,

very cool idea to share some octane related scripts. I'm very new to scripting, but solved a few of my problems with python.

I often have multiple shots in one Modo scene, which I store in actions. These Shots have different frameranges, which i write in the first and last frame channel in the render item.
The octane plugin always render the current timeframe. So this script reads the values of the current action and sets the timerange accordingly.

Code: Select all
#python
import modo
import lx

render = modo.Item('Render')

fpslst = [['film',24],['pal',25]]

first = float(render.channel('first').get())
last = float(render.channel('last').get())
fps = lx.eval('time.fps ?')

for cnt in range(0,len(fpslst)):
   if fps == fpslst[cnt][0]:
      fps = fpslst[cnt][1]

      
last = last/fps
first = first/fps

lx.eval('time.range current in:%s' % (first))
lx.eval('time.range current out:%s' % (last))
Hesekiel2517
Licensed Customer
Licensed Customer
 
Posts: 449
Joined: Mon Nov 23, 2015 10:57 pm

Re: OctaneRender for Modo SCRIPTS

Postby Hesekiel2517 » Mon Nov 22, 2021 12:23 pm

Hesekiel2517 Mon Nov 22, 2021 12:23 pm
Here is an unfinished script for batchrendering in octane for modo. Maybe there are some python experts, who want to help me with this.
Maybe you can also share your thoughts on this. Is this a good approach, do you have any workflow suggestions etc..
It's based on the great lua script, which can be found here: [url]https://render.otoy.com/forum
/viewtopic.php?f=73&t=70855[/url]

Edit: Forgot to add the script



Code: Select all
#python
import modo
import lx

def customfile(type, title, format, uname, ext, save_ext=None, path=None):
    ''' Custom file dialog wrapper function
 
        type  :   Type of dialog, string value, options are 'fileOpen' or 'fileSave'
        title :   Dialog title, string value.
        format:   file format, tuple of string values
        uname :   internal name
        ext   :   tuple of file extension filter strings
        save_ext: output file extension for fileSave dialog
        path  :   optional default loacation to open dialog
 
    '''
    lx.eval("dialog.setup %s" % type)
    lx.eval("dialog.title {%s}" % (title))
    lx.eval("dialog.fileTypeCustom {%s} {%s} {%s} {%s}" % (format, uname, ext, save_ext))
    if type == 'fileSave' and save_ext != None:
        lx.eval("dialog.fileSaveFormat %s extension" % save_ext)
    if path != None:
        lx.eval('dialog.result {%s}' % path)
    try:
        lx.eval("dialog.open")
        return lx.eval("dialog.result ?")
    except:
        return None


#Static Data
octane_url = "C:\Program Files\OTOY\OctaneRender Enterprise 2021.1\octane.exe" #insert Octane.exe URL
batchscript_url =  "D:\\006_Scripslibrary\\04_Octane\\cmdBatchRender_2020.2.lua" #insert Sript URL
format = "EXR_16"


#Write Batch File
batchfile = customfile('fileSave', 'Save Batch File', ('BAT',), 'batch file', ('*.bat',),'bat') #choose Filename and Location of the Batchfile
orbxfile = customfile('fileSave', 'Save Orbx File', ('ORBX',), 'orbx file', ('*.orbx',),'orbx')  #choose Filename and Location of the Orbxfile
render_url = str(customfile('fileSave', 'Save EXR File', ('EXR',), 'exr file', ('*.exr',),'exr'))  #choose Filename and Location of the rendered Images

render_url = render_url.rstrip('.exr') #remove File Extension from URL

#Open Batch Textfile
f= open(batchfile,"a+")

#Add Line
line = '"'+octane_url+'" '+'"'+orbxfile+'" '+"--no-gui --script "+batchscript_url+" -A "+render_url+" "+format
f.write("%s\n" % (line))

#Close File
f.close()

#Export Orbx
lx.eval('octane.saveAnimation "%s"' % (orbxfile))
Last edited by Hesekiel2517 on Tue Nov 23, 2021 7:58 am, edited 2 times in total.
Hesekiel2517
Licensed Customer
Licensed Customer
 
Posts: 449
Joined: Mon Nov 23, 2015 10:57 pm

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Tue Nov 23, 2021 2:30 am

face_off Tue Nov 23, 2021 2:30 am
Here is an unfinished script for batchrendering in octane for modo. Maybe there are some python experts, who want to help me with this.
Maybe you can also share your thoughts on this. Is this a good approach, do you have any workflow suggestions etc..
It's based on the great lua script, which can be found here: [url]https://render.otoy.com/forum
/viewtopic.php?f=73&t=70855[/url]
Did you perhaps miss uploading the script? The video on it's own does not mean much to me, sorry.

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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Tue Dec 07, 2021 5:06 am

face_off Tue Dec 07, 2021 5:06 am
face_off wrote:
Here is an unfinished script for batchrendering in octane for modo. Maybe there are some python experts, who want to help me with this.
Maybe you can also share your thoughts on this. Is this a good approach, do you have any workflow suggestions etc..
It's based on the great lua script, which can be found here: [url]https://render.otoy.com/forum
/viewtopic.php?f=73&t=70855[/url]
Did you perhaps miss uploading the script? The video on it's own does not mean much to me, sorry.

Paul
I see your script now. In general, I would have thought it easier to do this sort of rendering within the plugin. I will post a sample script below....

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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Tue Dec 07, 2021 5:11 am

face_off Tue Dec 07, 2021 5:11 am
Following is a very simple script to render all the Passes from the currently selected Pass Groups. Change the "filename" as required. This is had no testing, so please leave feedback here with your findings.

Thanks

Paul

Code removed - please see https://render.otoy.com/forum/viewtopic.php?f=34&t=78755&p=421892#p421892 for latest version.
Last edited by face_off on Wed Feb 15, 2023 6:13 am, edited 1 time in total.
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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: OctaneRender for Modo SCRIPTS

Postby Hesekiel2517 » Sat Dec 11, 2021 8:14 pm

Hesekiel2517 Sat Dec 11, 2021 8:14 pm
Hey Paul,
thank you for the script! Looks great. Batch rendering in Standalone has a few advantages in my opinion:
First of all you can start rendering while working on the scene and prepare the next shot and add that to the list. Its easy to change the order of the shots to render and it's very easy to override certain settings for all shots (like max samples). Also you can add a shutdown command (I guess this is also possible in modo).
Hesekiel2517
Licensed Customer
Licensed Customer
 
Posts: 449
Joined: Mon Nov 23, 2015 10:57 pm

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Sun Dec 12, 2021 10:13 am

face_off Sun Dec 12, 2021 10:13 am
Hesekiel2517 wrote:Hey Paul,
thank you for the script! Looks great. Batch rendering in Standalone has a few advantages in my opinion:
First of all you can start rendering while working on the scene and prepare the next shot and add that to the list. Its easy to change the order of the shots to render and it's very easy to override certain settings for all shots (like max samples). Also you can add a shutdown command (I guess this is also possible in modo).
Good points. If you have something specific you need to add to your script, let me know, and I can take a look.

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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia

Re: OctaneRender for Modo SCRIPTS

Postby BartvanDoornik » Wed Dec 15, 2021 9:22 am

BartvanDoornik Wed Dec 15, 2021 9:22 am
Hi,
awesome script if i could understand scripting. :)
I am kinda suprised this is not in the Plugin itself. I would love to have a dedicated button in the Octane menu/Octane renderwindow. Coming from Vray this is all in there and really handy if you need to render lots of takes.
Would be awesome if we can have a Render from Pass group popup like in Modo.

Hope you can build this in natively in Octane.
Thanks,
Bart
Attachments
renderPassGroup.png
renderPassGroup.png (10.25 KiB) Viewed 22995 times
BartvanDoornik
Licensed Customer
Licensed Customer
 
Posts: 14
Joined: Fri Nov 26, 2021 9:50 pm

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Tue Feb 15, 2022 5:52 am

face_off Tue Feb 15, 2022 5:52 am
Here is a script to move all the Octane Override assemblies into a separate Group to they do not clutter the Workspaces dropbox box (as requested at https://render.otoy.com/forum/viewtopic.php?f=34&t=79237)

Code: Select all
import modo
scene = modo.Scene()

scene_service = lx.service.Scene()
octane_override_type = scene_service.ItemTypeLookup("material.octaneRenderer")

# Build a list of assembly groups to move
list_of_groups_to_move = []
for group in scene.groups:
   for item in group.items:
      if item.TestType(octane_override_type):
         list_of_groups_to_move.append(group.name)

# Create the Octane Materials group if it does not already exist
try:
   octane_materials_group = modo.item.Group('Octane Materials')
except:
   octane_materials_group = scene.addGroup(name='Octane Materials')

# Process the list_of_groups_to_move list and set the groups parents to "Octane Materials"
for group_name in list_of_groups_to_move:
   group_item = modo.item.Group(group_name)
   group_item.SetParent(octane_materials_group)


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: 15471
Joined: Fri May 25, 2012 10:52 am
Location: Adelaide, Australia
Next

Return to Foundry Modo


Who is online

Users browsing this forum: No registered users and 8 guests

Fri Mar 29, 2024 12:13 am [ UTC ]