Forum: Poser Python Scripting


Subject: How do I write to a file?

Anthony Appleyard opened this issue on Jul 17, 2021 ยท 9 posts


HartyBart posted Sat, 17 July 2021 at 1:13 PM

Wow, who knew - (2) can be done from PoserPython, and does not even need (1) and (3). It should then by possible to have the script write many of the scene settings to a text file, along with the render, as a memory jogger for a later time.

At its simplest, tested and working on Poser 11:

import poser

scene = poser.Scene()

textfile = open(r'C:|Users|YOURNAME|Desktop|example.txt', 'w')
a = textfile.write('The quick brown fox')
textfile.close()

The forum software does not allow backslashes, and these have been substituted with | pipes. Replace these before use.

Works, but as it is it overwrites whatever text is in the file already. But it can get a lot more complex than this - search Google for "Python write String to a file" to find guides with examples.



Learn the Secrets of Poser 11 and Line-art Filters.