How to Automate Your Rendering Using KeyShot Scripting

by | Feb 15, 2017 | 0 comments

What is Scripting?

KeyShot Scripting allows you to automate repetitive task and build other customizations for KeyShot. KeyShot uses Python scripting, introduced with KeyShot 6.0, to provide you with more automation and reduce time-consuming processes. Automating tasks through scripts is also a great way to eliminate human error that often occurs when trying to produce consistent results.

Though KeyShot Scripting can be used in a variety of ways, today we’ll show you how it can be used to import a model, apply materials, queue several camera views and render them all out in a location of your choice. Through this, we’ll show that, with a few button clicks, you can set up a process and walk away from your computer as it renders out hundreds or even thousands of material and camera combinations.

Setting Up the Scene

Our scene is a toy train – four toy trains, as a matter of fact. We want to automate the import, material application and rendering of each. This can all be done with a single script in KeyShot. Our KeyShot scene includes three parts:

  • Four different 3D models
  • Three different camera angles
  • Two different material combinations

We’ll render each model, using each material set, at each camera angle, for a total of 24 renderings, and we’ll use a custom script to automate the entire process.

Download the Sample Files

There are four items needed for this script to automate the rendering of our models. Each item is included in the following download.

  1. The KeyShot .bip file (which contains all cameras to be rendered)
  2. The model or models (to be imported to the KeyShot scene and rendered)
  3. The material template (automatically applies KeyShot materials to the models)
  4. The Python script (which will tell KeyShot how to automate this process)
 

Overview of the Process Script

Once we have the four items above, the following steps make up the entire process. We’ll follow the same five steps for any models we want to run through the same type of operation.

  1. Open the .bip file
  2. Import material templates
  3. Load the script
  4. Specify settings
  5. Run the script

When you load the script, KeyShot will display the dialog to specify the settings for the script, then goes to work when you run it. The models will load, materials will be applied, cameras will be activated and job queued for each model we have. If we diagramed the script operation, it would look like this:

keyshot-scripting-overview-example-03.jpg

Step-By-Step

  1. Unzip ToyTrain.zip and open ToyTrain.bip in KeyShot.
  2. In KeyShot, go to Windows, Material Templates… select Import keyshot-material-template-import-icon-00.jpg and load ToyTrain_Realistic.kmtp and ToyTrain_Toon.kmtp from the Materials folder.
  3. In KeyShot, go to Windows, Scripting Console… or select Scripting keyshot-scripting-icon-00.jpg on the toolbar
  4.  Load the ToyTrain_BatchRender.py script from the Scripts folder.
  5. Click Run. A dialogue box appears to specify your settings.
    1. Set the import location of the model files.
    2. Set the image file type and output location.
    3. Specify the render settings for the images to be rendered.
    4. Option 1: Check the box to render an additional Toon version.
    5. Option 2: Check the Process Queue checkbox to begin rendering immediately each view is added to the render queue. Do not check this box if you’d like to review the renderings in the render queue before letting KeyShot render.

Now, you can go eat, take your dog for a walk, do the laundry, or watch a movie… while your computer does all the work! Nice, huh?

Creating Your Own Scripts

This tutorial is simply one example of what can be achieved using KeyShot’s powerful Scripting capabilities. For further reading on scripting, consult our quick start guide, or visit the KeyShot Forum Scripting board.

Additional Tips

Notepad++ is a great, free text editor for Windows Users.
The Notepad++ Compare plugin is useful for comparing scripts side-by-side

Try KeyShot Pro Today

Interested in trying KeyShot Pro?

Written By KeyShot

The KeyShot crew fills you in with the latest KeyShot tips and tricks, insight into 3D rendering technology and the people creating the coolest visuals across the engineering, product design and entertainment industries.

Categories

Recent Posts

The Winners of the 2024 KeyShot Animation Challenge

The Winners of the 2024 KeyShot Animation Challenge

Talk about bringing your renderings to life! Our first design challenge of 2024 was all about making your renderings move with KeyShot’s animation features like Physics Simulation and Camera Keyframes. Our judges were delighted by the hundreds of submissions to this contest, and they narrowed it down to the top three winners plus an honorable mention.

KeyShot vs Blender: Which One is Best?

KeyShot vs Blender: Which One is Best?

Explore how render farms enhance rendering workflows, offering insights into types, workings, and the integration of KeyShot for optimal efficiency.

Find Us on Facebook

Archive

[archives type="monthly" limit="3" tag="div"/]

YOU MIGHT ALSO LIKE

COMMENTS

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *