Saving the Python output as textfile?

So, what I would do is create an empty string at the beginning of the script, then start adding to it all the different lines of text that you want to output at the end - with a '\n' after each line to create a line break.

When you’re done, you’ll have one multiline string to output. You can then either write that to a text file with normal python text file writing methods or output to a Rhino message box. Python file write:

#filename is complete path to file plus name and .txt extension
file = open('filename', 'w')
file.write(your_multiline_string)
file.close()

Unfortunately, the TextOut() command - which writes text to a text window inside Rhino - is not implemented yet in Python rhinoscriptsyntax, all you have is MessageBox() currently.

–Mitch

1 Like