Exporting image by python commands

Dear all,

I have a problem with creating a hardcopy/image of my model when I am running Trelis by a python script. Here is a simple example:

[code]import sys


import cubit
print ‘error importing cubit, check if cubit is installed’

cubit.cmd(‘brick x 10 y 10 z 10’)
cubit.cmd(‘mesh volume 1’)

screen shot

cubit.cmd(‘hardcopy ‘test.png’ png’)[/code]

This is the content of my python script “test.py” which I am running in the command line of my Linux terminal. In the terminal it says ‘Journaled Command: hardcopy “test.png” png’ – but no image is created.
Can anyone tell me why? Do I somehow have to activate graphics?
If yes, how could I run Trelis with a GUI in the command line?

Best regards,


Correct. You will need to have the GUI running to take a screenshot using the hardcopy command. Here is a link to information about running Trelis from a command line.

csimsoft.com/help/environment_c … syntax.htm

Thank you!
But that exactly is my question - of course I have been on the website.

What is the command line to get the GUI running? I do not manage to get that running.

Best regards,

You should be able to use subprocess.Popen to launch an executable from Python.

import subprocess
subprocess.Popen([‘C:\Program Files\Trelis 16.5.1\bin\trelis.exe’])