tnpir4002 opened this issue on Sep 30, 2024 ยท 10 posts
tnpir4002 posted Mon, 30 September 2024 at 4:45 PM
Simple enough request, but the reality of it is proving to be problematic. Short and sweet: is there any way to batch render the PZ3s in a folder and export MP4s of all of them with specific settings?
I've been trying all day to come up with a Python script that will do it, but no matter what avenue I try I just get a faceful of errors. Has anyone else tried this? Or is there another method that I'm not seeing?
HartyBart posted Thu, 24 October 2024 at 3:57 PM
D3D's "Render Scenes" script shipped with Poser 11 as standard. From the readme: "'Render scenes' is a batch render[er] for several scene files". Only for images, but the script is in plain text and hackable Python, and looks at first glance like it could be made to do what you want with a little hacking.
It was not included in Poser 13. Needs WX for its UI, and I vaguely recall that Apple banned WX on Macs (along with so much else)? So perhaps, 'Windows only'?
This simple Poser script for rendering a frame from multiple mo-cap files looks like it has some interesting code ... https://gist.github.com/erfannoury/76c839b96ebd17aa2102
Learn the Secrets of Poser 11 and Line-art Filters.
tnpir4002 posted Thu, 24 October 2024 at 4:03 PM
Considering I HAVE Poser 11 you'd think I'd have realized this...looks like it didn't ship with Poser 12 either so I don't feel quite so bad. This is a GREAT tip though and I really appreciate it!!!
HartyBart posted Fri, 25 October 2024 at 8:42 AM
Learn the Secrets of Poser 11 and Line-art Filters.
tnpir4002 posted Fri, 25 October 2024 at 9:07 AM
If I can figure it out I definitely will!
nerd posted Sat, 26 October 2024 at 5:02 PM Forum Moderator
Sadly, Raif Sesseler the person behind D3D passed several years ago. We tried to acquire the rights and code from his estate. No one handling his affairs seemed to be able to do this. That's why it was left out of Poser after P12. We don't have the rights to distribute it.
HartyBart posted Sun, 27 October 2024 at 11:15 AM
Ah, well here is D3D's 2008 "Three Poser Python scripts to set up FireFly renders and to batch render poses and scenes", posted by the man himself on Renderosity Freestuff, and flagged by him as "licensed for commercial or non-commercial use". https://www.renderosity.com/freestuff/items/51547/render-11 Includes renderscenes.py
Presumably, given the permissive licence, this could now be forked and 'tickled up a bit' to work for Poser 14 (I recall it didn't work in Poser 11)? The script itself does say simply "copyright" in the header, but presumably his later posting of the script(s) under a permissive licence voids that?
Learn the Secrets of Poser 11 and Line-art Filters.
tnpir4002 posted Sun, 27 October 2024 at 11:33 AM
I didn't crack the code for MP4s, but thanks to ChatGPT I did get this to work exactly as I need it to with Poser 12 for PNG sequences. Turns out this is a better solution for what I'm doing anyway, since the Preview engine can't render proper alpha channels in Silhouette mode. AfterEffects is able to import the PNGs as a PNG sequence and treat them exactly as they would an MP4, which for my purposes works precisely the way I need.
Code:
import os
import poser
import time
# Directory containing the .pz3 files
selected_directory = r"C:\Path\to\Your\Files"
# Find and process all .pz3 files in the directory
pz3_files = [f for f in os.listdir(selected_directory) if f.lower().endswith('.pz3')]
if not pz3_files:
print("No PZ3 files found in the directory.")
else:
for pz3_file in pz3_files:
pz3_path = os.path.join(selected_directory, pz3_file)
try:
# Open the PZ3 file
print(f"Attempting to open {pz3_path}")
poser.OpenDocument(pz3_path)
time.sleep(2) # Wait to ensure document loads fully
# Access the current scene
scene = poser.Scene()
if scene is None:
print(f"Warning: No scene found after opening {pz3_path}")
continue
print(f"Successfully accessed {pz3_path}")
# Set render engine to Preview using SetCurrentRenderEngine
scene.SetCurrentRenderEngine(poser.kRenderEngineCodePREVIEW)
print("Render engine set to Preview.")
# Set display style to Texture Shaded
scene.SetDisplayStyle(10) # 10 is Texture Shaded
print(f"Display style set to Texture Shaded for {pz3_file}.")
# Determine output path and base filename
base_name, _ = os.path.splitext(pz3_file)
output_folder = os.path.dirname(pz3_path)
# Render each frame in the animation sequence to PNG
num_frames = scene.NumFrames()
for frame in range(num_frames):
scene.SetFrame(frame) # Set the current frame
output_filename = f"{base_name}_{frame+1:04d}.png" # e.g., filename_0001.png
output_path = os.path.join(output_folder, output_filename)
# Render the frame to the specified output path
scene.Render()
scene.SaveImage("png", output_path)
print(f"Rendered frame {frame+1} to {output_path}")
# Close the document without saving
poser.CloseDocument()
print(f"Successfully closed {pz3_file}\n")
except AttributeError as attr_err:
print(f"Attribute error while processing {pz3_file}: {attr_err}")
except Exception as e:
print(f"Unexpected error while processing {pz3_file}: {e}")
HartyBart posted Sun, 27 October 2024 at 12:08 PM
Here is a some PoserPython and Poser-specific code for MP4s which may be useful...
Learn the Secrets of Poser 11 and Line-art Filters.
HartyBart posted Sun, 27 October 2024 at 12:21 PM
Looks good, thanks for posting, and glad it's working. For ease of reading, here's the formatted script...
Learn the Secrets of Poser 11 and Line-art Filters.