Pass parameters to a journal/python file

How to pass parameters to a python/journal file?

If I have a simple Python script as below:

cubit.cmd(‘bri x {0}’.format(brick_size))

If I want to send in a parameter brick_size to this simple script, how do I do it?

How to pass parameters to a python/journal file while running Trelis from command line? If I am trying to run the above script simplebrick.jou from command line as
trelis simplebrick.jou

How should I pass it a parameter brick_size=10

You might try using a journal file that is a list of parameters in addition to the journal file with the commands.


I managed to transfer a python variable to my journal file by defining an aprepro variable after starting cubit. This loads the variable n (with the same value as r_i) that can then be used by the journal file test.jou.

import cubit cubit.init(['']) r_i=39 #variable assignment within python cubit.cmd('#{n=%s' % (r_i)) #assigning aprepro variable n to a string which has value r_i=39 cubit.cmd('play "test.jou"') #running test.jou journal file

In test.jou there is the line:

create Cylinder height 50 radius {n} 

which creates a cylinder of radius r_i=39

1 Like