Page 3 of 3

Re: OctaneRender for Modo SCRIPTS

Posted: Sat Feb 04, 2023 12:37 am
by face_off
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

Re: OctaneRender for Modo SCRIPTS

Posted: Wed Feb 15, 2023 6:11 am
by face_off
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()

Re: OctaneRender for Modo SCRIPTS

Posted: Wed Feb 15, 2023 6:54 am
by face_off
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()

Re: OctaneRender for Modo SCRIPTS

Posted: Sun Aug 27, 2023 11:53 am
by Hesekiel2517
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.

Re: OctaneRender for Modo SCRIPTS

Posted: Sun Aug 27, 2023 10:42 pm
by face_off
Awesome - thanks for sharing.

Re: OctaneRender for Modo SCRIPTS

Posted: Mon Sep 09, 2024 11:16 am
by Dingbat
face_off wrote: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()
any way to get this to work with MODO 14?

Re: OctaneRender for Modo SCRIPTS

Posted: Wed Sep 11, 2024 10:57 am
by face_off
any way to get this to work with MODO 14?
I believe that Modo14 uses python2, so I think you would need some good python coding skills to get these scripts working with Modo14. The Octane plugin is supported for Modo 15-17.

Thanks

Paul