Auto Shutdown Script of Keyshot

Anyone has an auto shutdown script of Keyshot, which means it will automatically shut down the computer when Keyshot finishes the render job queues, or do you have any other ideas about this?
Since I always need to do batch renderings of products, if it could be solved, I think I can leave the computer running with Keyshot Rendering alone, and set the auto shutdown script or any other software to control when to shut down the computer automatically.
Thanks!

I also had this feature in my feature request document, I think it would be nice. Some other software I use have it as well.

Python can do it I think so basically you need to start rendering your queue using Python and trigger the shutdown when it finished the queue. Think it would be only a couple of lines of script, I might puzzle a bit if I can pull it off but I’m a total noob with Python.

1 Like

I have no knowledge of Python what so ever, but I tried asking ChatGPT to write a script just for fun and it managed to give me a script which looks like it could work, from what I can tell. Not sure if it starts the queue or if it just starts single renderings, but I assume that that part of the code can be easily changed to do either.

import subprocess
import time

# Define the path to the KeyShot executable and the project file
keyshot_executable = 'path/to/KeyShot.exe'
project_file = 'path/to/your/project.ksp'

# Define a function to start KeyShot rendering
def start_keyshot_render():
    command = [keyshot_executable, '-b', project_file]
    subprocess.Popen(command)

# Define a function to check if KeyShot is running
def is_keyshot_running():
    process_list = subprocess.Popen(['tasklist'], stdout=subprocess.PIPE, text=True)
    return 'KeyShot.exe' in process_list.stdout

# Define a function to turn off the computer
def turn_off_computer():
    subprocess.Popen(['shutdown', '/s', '/t', '0'])

# Start the KeyShot rendering
start_keyshot_render()

# Check if KeyShot is running and wait until it finishes
while is_keyshot_running():
    time.sleep(10)  # Adjust the sleep duration as needed

# KeyShot rendering is finished; now turn off the computer
turn_off_computer()

Before using this script, make sure to:

  1. Replace 'path/to/KeyShot.exe' with the actual path to your KeyShot executable.
  2. Replace 'path/to/your/project.ksp' with the actual path to your KeyShot project file.
  3. Make sure you have Python installed on your computer.

Here’s how the script works:

  1. It starts KeyShot in the background to render your project using the subprocess module.
  2. It checks if KeyShot is still running in a loop with a sleep duration. Once KeyShot is no longer running, it proceeds to the next step.
  3. After the rendering is finished, it uses the shutdown command to turn off the computer.

Might be worth giving it a try if you don’t want to/know how to write the code yourself!

1 Like

Thanks, it looks deserves to have a try, I was thinking about writing a python monitor that can monitor the rendering queues console, and when the queue console is empty, it shuts down the computer.

As Joakim Eriksson said, you can try on ChatGPT, maybe you’ll get a new wonderful skill, hahahahahah

Haha, who knows. I only tried ChatGPT a few times to make up some promotional texts for objects I created. That works really well, especially since I don’t know much blabla marketing words in English to make things fancier as they are.

3 Likes

Chatgpt?
Chatgtp doesn’t really know the keyshot.
It only tells you the code that doesn’t work with weird code.
Like this:…

import scripting
scripting.start_process()
render_settings = scripting.get_current_render_settings()
render_settings.width = 1920
render_settings.height = 1080
scripting.set_current_render_settings(render_settings)
scripting.render()
scripting.shutdown()

Hence why I stated that I have no knowledge of Python and didn’t know if the result would work or not. It was just a test to see what it would produce, for fun.