The point of writing and sharing many of these Python scripts has been to automate certain repetitive tasks in Terragen, reducing them down to one or two button clicks. There's currently seventeen scripts available on the Planetside Software Forums; and there will be more!
But how do we easily access these scripts in the first place? Here's a teaser to where this post is heading:
To start with, my computer has a folder where I put all my Terragen scripts. Within that folder is a subfolder for each script and any supporting files. This is nice in terms of organization, but the idea of having to navigate to the scripts folder, then the subscripts folder, then double clicking on the Python file to run it makes me tired just thinking about it.
So I made an image to use as an icon, and added a shortcut to the Python script and placed it on my desktop. This was great, because now I could just click the icon like any other program and the script would run. But as time went on and I added more and more icons, my desktop became cluttered and confusing.
Then I thought to myself, why not make one script that has a bunch of buttons that will run all the other scripts? This too worked great, for a time, but I was listing each button one above the other and soon ran out of vertical real estate.
So I changed the layout of the UI to use tabs instead, and this brought peace of mind, at least until I decided to share the setup on the forums.
The problem is that it works fine on my system, but not necessarily anyone else's. For example, you may or may not have a drive mapped as "P:" on your system that contains all your scripts. And that my friends, has led to the latest incarnation of the script, in which I decided to get ChatGPT involved just for fun.
The idea behind this script is that when you run it, it will automatically create a User Interface with buttons for all your scripts. It's based on the information you provide in a config file, which is a simple text file and can be easily edited. Instead of reinventing the wheel for the config file, I chose to use the Tom's Obvious, Minimal Language (TOML) file format because it comes highly recommended for Python programming and works on all major operating systems.
The TOML format allows you to customize your UI. For example, the default config file shown at the top of this post includes tabs that mirror Terragen's toolbar, plus a Utility tab. Some of these tabs don't have any scripts yet, so to remove those tabs you can simply "comment" out that line of code in the config file using a hash "#" symbol. That will give you a UI that looks like this:
If you don't like lots of tabs, you can just as easily put all the scripts under one tab.
I admit that the layout of the config file itself isn't pretty, but on the other hand, it's not too difficult to understand either. Let's quickly break it down so you can start customizing it for your own system (which you
will need to do). Here's a portion of the config file as an example:
[[category]]
name = "Cameras"
scripts = [
{ path = "P:/Git_Repo/tg-camera-bookmarks/tg_camera_bookmarks.py", label = "Camera Bookmarks", shortcut = "<b>" },
{ path = "P:/Git_Repo/tg-crop-region-presets/tg_crop_regions_presets.py", label = "Crop Regions", shortcut = "Shift-c" }
]
[[category]]
name = "Clouds"
scripts = [
{path = "P:/Git_Repo/tg-add-random-cloud/tg_add_random_cloud.py", label = "Add Random Cloud", shortcut = "Control-c"}
]
You can see that each section starts with
[[category]]. Use this any time you want to add something new to your UI. In our Python script these categories will show up as tabs on the interface with the
label you provide in quotes, for example "Camera" or "Clouds".
Enclosed in the
scripts[] section are any scripts that you want included under this category.
Each script and its options are enclosed within braces
{}. The options include full file path, label and shortcut.
Set the
path option to the full path of your script.
The
label option is used for the button name. If you don't include this option, the Python script name is used.
The
shortcut option defines a keyboard shortcut. This is optional, but a game changer too. You can use a single key, or combinations with the Shift and Control key but
NOT the ALT key. Think of the ALT key as reserved for operating system stuff, i.e. other system programs are already using it, so it's best just to avoid that key. When assigning a single key, enclose it within angle brackets like this "<g>", but when assigning keyboard combinations like Shift and Control, just put the combination inside quotes like this "Control-k".
When the script's UI has focus, you can use the keyboard shortcuts. This means that your scripts are only one or two button clicks away at any time. One click to focus the computer on the script's UI, and one click to run the script or press the keyboard shortcut. If focus is already set to the script's UI, then you're just one click away!
Using ChatGPT, it took about 20 iterations for me to get the script where it needed to be. I made a few aesthetic modifications to make the UI more readable, but for the most part I left the code as it had been generated so you can read the explanatory comments that ChatGPT writes when it creates code.
This script is one of the two ways that I know how to get your scripts closer to your fingertips, and increase productivity in Terragen. I like it because it's free and can be customized fairly easily. I'll be posting the other method shortly. Until then, don't forget to smash the Like button and subscribe... oh wait, wrong venue...here's the script:
https://github.com/RedMawVFX/tg-dashboard.git