How can I deliver vector type variables in Python to Itasca command?

I have tried to create wall in PFC3D by using Python script.
However, it fails to deliver vector type variable to Itasca command.
Please check the following script.


get_ipython().magic(‘reset -sf’)
import itasca as it
from vec import vec

it.command(""“model new
model configure dynamic
model deterministic off
model large-strain on”"")

it.command(""“model domain extent -0.08 0.08
domain condition destroy”"")

def create_wall():
p11 = vec((-0.01, -0.01, -0.01))
p22 = vec((0.01, 0.01, -0.01))
p33 = vec((-0.01, 0.01, -0.01))
p44 = vec((0.01, -0.01, -0.01))
it.command(""“wall generate id 1 name ‘bottom’ polygon {p11} {p44} {p22} {p33}”"")


*** Python error: ‘At least 3 vertices must be specified.\n While processing line 0 of source Python interpreter.’

it.command(f""“wall generate id 1 name ‘bottom’ polygon {p11.x()} {p11.y()} {p11.z()} …
{p22.x()} {p22.y()} {p22.z()} …
{p33.x()} {p33.y()} {p33.z()} …
{p44.x()} {p44.y()} {p44.z()} ”"")

Thank you Huy.
The following format also works. Regards.

it.command(""" {} {} {}""".format( .x(), .y(), .z()))

Yes, it’s the old syntax for Python 2. In Python 3, you can put “f” in front of the string.

looks like Python tuples are converted into FISH vectors. So, you can try declaring p11 as tuple instead of vec.

Thanks to you xpnguyen, the code has become simple.

Dear Huy
How can I deliver the data in the List type between Fish and Python? Do you have any suggestions?

Hi Hansenn,
You can get a list from Fish in python using the function"listFish").
However, right now the function does not allow to set a list or np.array from Python to a list in Fish, What you can do is do a loop over Python list and append each element into Fish list.

for i in pyList:
    it.command("[fishList('end') = {i}]")

or you can export the Python list into a data file and import again in Fish

Thanks a lot, Huy. What’s the time the function of will be used? Does the Itasca have the schedule? Itasca’s software will be more powerful If the data can be delivered freely between Fish and Python.