Automate my renderings with Cycles

Please could you help me to automate my renderings with Cycles ? How to do?
I’m usine RG6.6 version.
Thank you so much

First I suggest you update Rhino.

Then you can use Grasshopper.

Ah yes you’ll have to install GhShadeNodes plugin for Rhino/Grasshopper. Run the command _TestPackageManager install from there then restart rhino

thank you for replying me.
and after that should it be possible to use renderstudio presets ?

No need to use Grasshopper for render automation.

All you need is to script the ViewCaptureToFile and do some scene management.

@gdomecq, can you elaborate on what aspect you want to automate? Materials? Textures? Environments? Rendering of a set of 3dm files?

1 Like

@jesterKing I would like to automate materials (gold, silver, … different colors of stones) for rendering of a set of bmp files

Then you need Grasshopper (GhShaderNodes) I guess.

Here are a few threads I recently created about that topic:

Sorry, but it’s not what I’d like to do…
i want to ude the same tool than Rhinogold 4 but not activated with Rhinogold 6.6.

Ah, I didn’t know RG means Rhinogold. I thought it was a typo :smiley:

I’m not familiar with this plugin, sorry.

oh ok :slight_smile:
but may be you have one solution.

I don’t know how to script… I need help …

For that I need to understand how Rhinogold works, does it use Rhino materials? If so you just need to get your model inside Grasshopper then the above links can help you set up the model for rendering.

No you don’t.

As long as you have access to the materials you can write a script that assigns a material to the object of choice, then crunches out a ViewCaptureToFile with the Raytraced engine, then goes on the next material and so on.

I’ll type an example later tonight, or if I don’t manage during my weekend I’ll do it tomorrow.

This is what I essentially do for my regression test suite, although there I mainly do environment switching - it will work the same. I crunch out around a 1000 images for my test suite.

1 Like

Thank you, I’m waiting for your example because I don’t know how to write a script…


The reason I do everything in Grasshopper first is because it’s a visual programming if someone wants to understand the workflow it’s easier to read grasshopper algorithm than a script. You can always switch to just script afterwards.

Here’s a video of my current workflow, although it’s kind of difficult to debug the wrong result. You can see me struggling :smiley:

I can. Do start a new thread for that if you want to ask about it. For the sake of this thread: this doesn’t help in automating renderings.

@gdomecq, writing the script goes to Monday. While this further mulls in my head would the following procedure be close to what you want?

  • have a model with several objects, of which one should be rendered with different materials
  • have several materials in the model
  • loop through each (wanted) material
    • assign to object
    • switch to Raytraced (for as few samples as possible)
    • create a -:ViewCaptureToFile with a certain resolution

Hi Nathan,

Is it possible and you have time (and desire :slight_smile: ) when you make the script. Could you also make use of UserText attribute and/or layer and/or group as a material assignment criteria.

That is if you want to make a more powerful script. I can imagine in most cases there are objects that have been duplicated.

I remember you mentioning that there’s something you need to fix. So whenever you can fix it. No need for another thread.


Attached a simple (and not fault-tolerant) script, along with a sample model. (1.5 KB)

MaterialSwitcherAndAutomatedRendering.3dm (993.0 KB)

The script looks like this

# Material switcher
# and Raytraced viewcapturing

import scriptcontext as sc
import Rhino.Render as rr
import Rhino as r
import Rhino.DocObjects as rdob

import System

av = sc.doc.Views.ActiveView

cycles = sc.doc.Views.ActiveView.RealtimeDisplayMode
oldpasses = cycles.MaxPasses
cycles.MaxPasses = 2

def capture_viewport(name):
	cycles.Paused = True
	view_capture = r.Display.ViewCapture()
	view_capture.Width = av.ActiveViewport.Size.Width
	view_capture.Height = av.ActiveViewport.Size.Height
	view_capture.ScaleScreenItems = False
	view_capture.DrawAxes = False
	view_capture.DrawGrid = False
	view_capture.DrawGridAxes = False
	view_capture.TransparentBackground = False
	view_capture.RealtimeRenderPasses = 10
	bitmap = view_capture.CaptureToBitmap(av)
	if bitmap:
		folder = System.Environment.SpecialFolder.Desktop
		path = System.Environment.GetFolderPath(folder)
		filename = System.IO.Path.Combine(path, name + "_raytraced_capture.png")
		print("saving ", filename)
		bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png)

selobs = [ob for ob in sc.doc.Objects if ob.IsSelected(False)>0]

if len(selobs) > 0:

	showroom_materials = [rm for rm in sc.doc.RenderMaterials if rm.Tags and rm.Tags.find("ShowRoom")>-1]
	for rm in showroom_materials:	
		for ob in selobs:
			ob.RenderMaterial = rm
		print("capturing with ", rm.Name)
	print("no capturing today")

cycles.MaxPasses = oldpasses
cycles.Paused = False

It works by having a view set to `Raytraced` and the object(s) you want to have the materials switched on selected.

The materials you want to use should be in the material editor. Those you wish to use also need to have the tag `ShowRoom` set.  This tag is used to gather all the materials in a list.

With the object selected use  `_EditPythonScript` and load the attached Python file (or copy/paste in empty script from this post).

When you select to run it you'll see that the maximum passes of the  active `Raytraced` view is changed to two. After each material application `Raytraced` is paused and then a view capture is generated of that view. Once successfully completed the capture is saved to the desktop with the name of the material and "_raytraced_capture.png"  combined.

In this sample script I have set the passes to 10 - increase that to get the required quality.

Also set the Width and Height of the view capture to something you want - if the current viewport size is good just leave the current code in.

With the sample model loaded running the script should give you four captures on your desktop.

On purpose I left a lot of niceties and handling out - I wanted to give a springboard for the community to build out a user-friendlier script :) At least filename handling should be taken care of. Right now you shouldn't use characters in material names that are forbidden in filenames, like colons, equals, asterisk, etc.

I hope that despite that it can be already useful in its current state.

Hello, sorry for the wait

I would like something like that :

Thank you

You mean you want that functionality withour having to get RhinoGold?

I have Rhinogold 6.6 ! but this fonctionality doesn’t works …according to Cadlink, this fonctionaliy was not updated / plug

Sorry, I don’t know RhinoGold. You’ll have to contact the developer for that.

I hope that otherwise my script can be of use for someone.