Update: I've figured out how to change the resolution and the name of the output image file by modifying the XML in the '.chaos' file. Of course I understand that the format of the XML might change in a future release of Chaotica, but I'll take that chance. The only thing standing in the way of full automation (letting it run unattended) is the fact that the app doesn't close when the batch is finished, so I have to monitor it as it runs and close each Chaoatica window when the rendering is done. Maybe they'll consider adding another command-line option to do this, or modify the behaviour of the '-batch' option to close automatically.
Also, I still haven't figured out what the 'silent' option is supposed to do, as it doesn't seem to do anything at the moment. Is it broken?
For anyone interested in trying to script Chaotica using Python, here's the code. The script will search for files matching the pattern specified on the command line (you can use wildcards '?' and '*' in the file name) and for each world file it finds, render it in each of the resolutions specified in the table (see code listing below). You can add more resolutions by editing the table. If you're not running under Windows, or you installed Chaotica in some directory other than the default, you'll also have to change the line with 'subprocess.call()'.
Code:
# -*- coding: utf-8 -*-
"""
Created on Sat May 15 08:40:41 2021
@author: David Kettle
"""
import sys, os, subprocess, glob
import xml.etree.ElementTree as ET
def render (file, width, height):
name = os.path.basename(file).split('.')[0]
ext = os.path.basename(file).split('.')[1]
path = os.path.dirname(file)
sep = os.sep
base = name + "-" + str(width) + 'X' + str(height)
ifile = path + sep + name + "-" + \
str(width) + 'X' + str(height) + "." + ext
tree = ET.parse(file)
root = tree.getroot()
for ifs in root.findall('IFS'):
ifs.set('name',base)
for image in ifs.findall('imaging'):
for elem in image.findall('int'):
name = elem.attrib.get('name')
if name == 'image_width':
elem.text = str(width)
if name == 'image_height':
elem.text = str(height)
tree.write(ifile,encoding='utf-8',xml_declaration=True)
# if not running under Windows, update the following line:
subprocess.call(['C:\Program Files\Chaotica\chaotica.exe',
'-o',path,
'-batch',
'-haltsl','8',
ifile],
shell=True)
os.remove(ifile)
if __name__ == "__main__":
# To add (or remove) resolutions, edit this table:
resolutions = [
# Retina Macbook Pro (16:10 aspect ratio)
[ 2560, 1600 ], # Macbook Pro 13"
[ 2880, 1800 ], # Macbook Pro 15"
# Windows, video (16:9 aspect ratio)
[ 1280, 720 ], # WXGA
[ 1920, 1080 ], # FHD
[ 3840, 2160 ] # 4K UHD
]
if len(sys.argv) < 2:
sys.stderr.write("No input files specified.\n")
sys.exit
for arg in sys.argv[1:]:
for file in glob.glob(arg):
for reso in resolutions:
print("Rendering "+file+" @ "+str(reso[0])+"X"+str(reso[1]))
try:
render(file,reso[0],reso[1])
except Exception:
sys.stderr.write("Not found or invalid: "+file+"\n")
sys.exit