Using Fish Global variable into a Python script

Hello everyone,

Lets suppose that I created a FISH variable called A and stored a value equal to 100 in there. Which in FLAC3D would be written something like [A=100]. Then, would it be possible to use the previous in a Python "if " or “for” routine for further instructions to be made in FLAC3D?, something like this:

if it.command(“[A>100]”):

it.command("model solve")

I’ve tried the above several times and by several ways, however I’ve been able to make it.

Can someone give me a hint on this?

Thank you in advance.

The Python variables and FISH variables are not directedly accessible, from or to. Use itasca.fish.get to read a FISH variable to Python, or use itasca.fish.set to set a variable into FISH.

Try:

A = it.fish.get(‘A’)
if A > 100:
[space] it.command(“model solve”)

2 Likes

Hi Cheng!

I really appreciate your help. At the moment is working pretty well.