OctaneRender for Modo SCRIPTS

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

Moderator: face_off

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Sat Feb 04, 2023 12:37 am

face_off Sat Feb 04, 2023 12:37 am
Render passes are ignoring pass visibility. Using Modo native or Vray it is extremely useful to be able to toggle off a pass using the little camera icon in the groups panel. Say you have a dozen passes but three of them you do not need to run, it can save a lot of wasted time. When I run the script for Octane it renders all passes ignoring that state.
You should be able to tweak the code to do this. It will be something like adding the lines:
Code: Select all
pass_state = lx.eval('layer.enable enable:?')
if pass_state == "off":
    continue

after the line
Code: Select all
render_pass_group = modo.item.RenderPassGroup(current_pass_group_name)

Remember to make sure the indentation is correct. If you have trouble, please PM me the code and I will take a closer 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 face_off » Wed Feb 15, 2023 6:11 am

face_off Wed Feb 15, 2023 6:11 am
Here is the latest version of the render pass rendering scripts. All previous version above have been removed.

Code: Select all
#python

#
# NOTE: Make sure you select the correct file extension (png or exr) to match the current "Save Image" -> "Save Format" in the Octane plugin toolbar
#

import modo
import lx

# Only runs on Modo15/16
import PySide2
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
from PySide2.QtWidgets import QFileDialog

# Get the file save name and location.  Enter the correct extension to match the Octane Save parameters (ie. .png or .exr)
path_to_file, _ = QFileDialog.getSaveFileName(None, "Save Files As...", None, "Images (*.png *.exr)")

if path_to_file != "":
   # Split the path into a filename/folder and an extension
   extension = path_to_file[path_to_file.rfind("."):]
   path_to_file = path_to_file[0:path_to_file.rfind(".")]

   # Get the currently select Pass Group
   current_pass_group_name = lx.eval('group.current ? pass')
   render_pass_group = modo.item.RenderPassGroup(current_pass_group_name)
   
   # Popup a progress window.  Remove the cancel button, as cancelling the render via the Render progress window should cancel all rendering
   progress = QProgressDialog("Rendering passes for " + render_pass_group.name, "Abort Rendering", 0, render_pass_group.itemCount, None)
   progress.setWindowModality(Qt.NonModal)
   progress.setWindowFlags(progress.windowFlags() ^ Qt.WindowStaysOnTopHint)
   progress.setCancelButton(None)
   progress.show()
   progress.move (progress.pos().x(), progress.pos().y() - 100)
   PySide2.QtWidgets.QApplication.processEvents()
   
   # Render and save each Pass in the current Pass Group
   action_clip_number = 0
   
   for action_clip in render_pass_group.passes:
      progress.setValue(action_clip_number)
      PySide2.QtWidgets.QApplication.processEvents()
      action_clip_number = action_clip_number + 1
      action_clip.active = True
      if action_clip.enabled:
          filename = path_to_file + "_" + action_clip.name +  extension
          try:
             result = lx.eval('octane.renderAndSave "' + filename + '"')
          except:
             break
     
   progress.setValue(action_clip_number)
   progress.hide()
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 » Wed Feb 15, 2023 6:54 am

face_off Wed Feb 15, 2023 6:54 am
Here is a variation on the above script which will export each pass to an ORBX file. IMPORTANT: Make sure the Octane Viewport is rendering prior to running this script.

Code: Select all
#python

#
# IMPORTANT: Make sure the Octane Viewport is rendering prior to running this script.
#

import modo
import lx

# Only runs on Modo15/16
import PySide2
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
from PySide2.QtWidgets import QFileDialog

# Get the file save name and location.  Enter the correct extension to match the Octane Save parameters (ie. .png or .exr)
path_to_file, _ = QFileDialog.getSaveFileName(None, "Save Files As...", None, "ORBX (*.orbx)")

if path_to_file != "":
   # Split the path into a filename/folder and an extension
   extension = path_to_file[path_to_file.rfind("."):]
   path_to_file = path_to_file[0:path_to_file.rfind(".")]

   # Get the currently select Pass Group
   current_pass_group_name = lx.eval('group.current ? pass')
   render_pass_group = modo.item.RenderPassGroup(current_pass_group_name)
   
   # Popup a progress window.  Remove the cancel button, as cancelling the render via the Render progress window should cancel all rendering
   progress = QProgressDialog("Rendering passes for " + render_pass_group.name, "Abort Rendering", 0, render_pass_group.itemCount, None)
   progress.setWindowModality(Qt.NonModal)
   progress.setWindowFlags(progress.windowFlags() ^ Qt.WindowStaysOnTopHint)
   progress.setCancelButton(None)
   progress.show()
   progress.move (progress.pos().x(), progress.pos().y() - 100)
   PySide2.QtWidgets.QApplication.processEvents()
   
   # Render and save each Pass in the current Pass Group
   action_clip_number = 0
   
   for action_clip in render_pass_group.passes:
      progress.setValue(action_clip_number)
      PySide2.QtWidgets.QApplication.processEvents()
      action_clip_number = action_clip_number + 1
      action_clip.active = True
      if action_clip.enabled:
          filename = path_to_file + "_" + action_clip.name +  extension
          try:
             result = lx.eval('octane.saveFrame "' + filename + '"')
          except:
             break
     
   progress.setValue(action_clip_number)
   progress.hide()
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 » Sun Aug 27, 2023 11:53 am

Hesekiel2517 Sun Aug 27, 2023 11:53 am
I was looking for an octane alternative to modos variation texture in item mode. Here is a script that assigns a weightmap with unique values to selected meshes. You can then use these with a greyscale vertex attribute texture in octane.

Code: Select all
# python

import lx

selected_items = lxu.select.ItemSelection().current()
x = 0

for item in selected_items:
   item_name = item.UniqueName()

   try:
      weight = x/(len(selected_items)-1)
   except:
      weight = 0
   lx.eval('select.drop item')
   lx.eval('select.subItem %s set mesh'%item_name)
   lx.eval('!vertMap.new Weight wght value:%f' %weight)
   
   print("Item Name: "+item_name + " Assigned Weight: " + str(weight))
   
   x = x+1

print("Processed Items: "+str(len(selected_items)))


Here is an alternative script that assigns a random seed value to each mesh. It's possible to use that with the random color texture in Octane. Thanks to funk for pointing that out.

Code: Select all
# python

import lx

selected_items = lxu.select.ItemSelection().current()
seed = 0

for item in selected_items:
   item_name = item.UniqueName()

   lx.eval('select.drop item')
   lx.eval('select.subItem %s set mesh'%item_name)
   try:
      lx.eval('item.channel oc_randomSeed %i'%seed)
   except:
      print("no randomSeed available")
   
   print("Item Name: "+item_name + " Assigned Seed: " + str(seed))
   
   seed += 1

print("Processed Items: "+str(len(selected_items)))


I hope this is useful to someone.
Hesekiel2517
Licensed Customer
Licensed Customer
 
Posts: 449
Joined: Mon Nov 23, 2015 10:57 pm

Re: OctaneRender for Modo SCRIPTS

Postby face_off » Sun Aug 27, 2023 10:42 pm

face_off Sun Aug 27, 2023 10:42 pm
Awesome - thanks for sharing.
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
Previous

Return to Foundry Modo


Who is online

Users browsing this forum: Google [Bot] and 3 guests

Thu Mar 28, 2024 10:37 am [ UTC ]