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

**URL:** <https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390>\
**Category:** General\
**Tags:** python\
**Created:** [March 25, 2022, 4:47pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390 "2022-03-25T16:47:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppk](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@ppk](https://forum.itascainternational.com/u/ppk)\
**Post date:** [March 25, 2022, 4:47pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/1 "2022-03-25T16:47:55Z")

</div>

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.

Regards.

====  
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}”"")

create\_wall()

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

---

<div class="post-metadata">

**Author:** ![Huy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@Huy](https://forum.itascainternational.com/u/Huy)\
**Post date:** [March 27, 2022, 12:20pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/2 "2022-03-27T12:20:05Z")

</div>

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()} ”"")

---

<div class="post-metadata">

**Author:** ![ppk](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@ppk](https://forum.itascainternational.com/u/ppk)\
**Post date:** [March 27, 2022, 1:09pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/3 "2022-03-27T13:09:48Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Huy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@Huy](https://forum.itascainternational.com/u/Huy)\
**Post date:** [March 27, 2022, 2:00pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/4 "2022-03-27T14:00:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xpnguyen](https://avatars.discourse-cdn.com/v4/letter/x/258eb7/32.png) [@xpnguyen](https://forum.itascainternational.com/u/xpnguyen)\
**Post date:** [March 28, 2022, 2:54pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/5 "2022-03-28T14:54:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ppk](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@ppk](https://forum.itascainternational.com/u/ppk)\
**Post date:** [March 29, 2022, 12:01pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/6 "2022-03-29T12:01:48Z")

</div>

Thanks to you xpnguyen, the code has become simple.

---

<div class="post-metadata">

**Author:** ![Hansenn](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@Hansenn](https://forum.itascainternational.com/u/Hansenn)\
**Post date:** [November 14, 2022, 3:56am UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/8 "2022-11-14T03:56:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Huy](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@Huy](https://forum.itascainternational.com/u/Huy)\
**Post date:** [November 14, 2022, 7:19am UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/9 "2022-11-14T07:19:54Z")

</div>

Hi Hansenn,  
You can get a list from Fish in python using the function `it.fish.get("listFish").`  
However, right now the function `it.fish.set()` 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.

```auto
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

---

<div class="post-metadata">

**Author:** ![Hansenn](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@Hansenn](https://forum.itascainternational.com/u/Hansenn)\
**Post date:** [November 14, 2022, 1:50pm UTC](https://forum.itascainternational.com/t/how-can-i-deliver-vector-type-variables-in-python-to-itasca-command/390/10 "2022-11-14T13:50:39Z")

</div>

> [@Huy](#):
>
> Python list

Thanks a lot, Huy. What’s the time the function of it.fish.set() 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.  
Regards,  
Hansenn
