# Custom Node - Input lists Error

**URL:** <https://forum.dynamobim.com/t/custom-node-input-lists-error/84439>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [December 25, 2022, 11:39am UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439 "2022-12-25T11:39:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![utech.udara](https://avatars.discourse-cdn.com/v4/letter/u/b782af/32.png) [@utech.udara](https://forum.dynamobim.com/u/utech.udara)\
**Post date:** [December 25, 2022, 11:39am UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/1 "2022-12-25T11:39:22Z")

</div>

Dear network,  
I am trying to create a custom node to draw plots using matplot lib. I need to give inputs as “lists” to my custom node, But an error occurs as follows,

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/3/f36925d9f0d3fc1a094db99605ba75cb19a83145.jpeg)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/92e3b657fb796bd8886110ae32191e48be1e431b.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [December 25, 2022, 12:30pm UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/2 "2022-12-25T12:30:09Z")

</div>

Hi @utech.udara ,

I am not an expert with creating custom nodes but you should use something like this (i think).

String and Int

(Or, if the first one doenst work) Var or Var…

Ps: do you need to specify the input types at all?

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [December 25, 2022, 7:22pm UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/3 "2022-12-25T19:22:23Z")

</div>

Hello,  
you have to look at the script by M. C. Poupin  
I tried but with I have trouble with python, if it can help you [Can I use matplotlib in Dynamo? - #5 by c.poupin](https://forum.dynamobim.com/t/can-i-use-matplotlib-in-dynamo/40608/5)

I attach what I tried to do

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/7/c7876f801ba777be192b7d47f407669dd8d06d77.png)

```auto
# Charger les bibliothèques DesignScript et Standard Python
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import os

clr.AddReference('System.Drawing')
import System.Drawing
from System.Drawing import *
from System.Drawing.Imaging import *
from System.IO import MemoryStream

localapp = os.getenv(r'LOCALAPPDATA')

sys.path.append(os.path.join(localapp, r'python-3.9.12-embed-amd64\Lib\site-packages'))
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import io
import math

# Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
a=IN[0]
b=IN[1]

# Placer votre code au-dessous de cette ligne
def plt2arr(fig):
    fig.canvas.draw()
    rgba_buf = fig.canvas.buffer_rgba()
    (w,h) = fig.canvas.get_width_height()
    rgba_arr = np.frombuffer(rgba_buf, dtype=np.uint8).reshape((h,w,4))
    return rgba_arr

def convertToBitmap2(npImgArray):
    bitmap_ = None
    # remove alpha
    if npImgArray.ndim == 3 and npImgArray.shape[-1] == 4:
        npImgArray = npImgArray[:, :, :-1]
    # convert to PIL Image
    if npImgArray.ndim == 3:
        image = Image.fromarray(npImgArray, "RGB")
    else:
        image = Image.fromarray(npImgArray, "L")
    # convert to Python ByteArray
    byteIO = io.BytesIO()
    image.save(byteIO, format='BMP')
    byteArr = byteIO.getvalue()
    # convert to Net ByteArray
    netBytes = System.Array[System.Byte](byteArr)
    with MemoryStream(netBytes) as ms:
        bitmap_ = Bitmap(ms)
    return bitmap_
    
xpoints = np.array(b[0])
ypoints = np.array(b[1])
plt.plot(xpoints,ypoints)
plt.xlabel(a[0])
plt.ylabel(a[1])
fig=plt.figure()
ax = fig.add_subplot(111)
ax.plot(xpoints,ypoints)
ax.set_xlabel(a[0])
ax.set_ylabel(a[1])

image_from_plot = plt2arr(fig)
bitmap1 = convertToBitmap2(image_from_plot)

# Affectez la sortie à la variable OUT.
OUT = bitmap1

```

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![utech.udara](https://avatars.discourse-cdn.com/v4/letter/u/b782af/32.png) [@utech.udara](https://forum.dynamobim.com/u/utech.udara)\
**Post date:** [December 26, 2022, 1:16pm UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/4 "2022-12-26T13:16:18Z")

</div>

@christian.stan Thank you for the reply. Yes, I have followed it and used the python fuction defined. However, the issue occurs when I create a custom node. The idea is to reuse the node at different locations rather creating python node repeatedly.

---

<div class="post-metadata">

**Author:** ![utech.udara](https://avatars.discourse-cdn.com/v4/letter/u/b782af/32.png) [@utech.udara](https://forum.dynamobim.com/u/utech.udara)\
**Post date:** [December 26, 2022, 1:18pm UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/5 "2022-12-26T13:18:39Z")

</div>

Hi!

But when I use **var** instead of **List** , then custom node take one item at a time. That’s the problem ☹

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [December 26, 2022, 1:58pm UTC](https://forum.dynamobim.com/t/custom-node-input-lists-error/84439/6 "2022-12-26T13:58:32Z")

</div>

Hello,  
I tried like this if can help you

 ![Capture d’écran 2022-12-26 145254](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/6/c6c6f5a212888be08c9f8c89c2fe6df1743c50b1.jpeg)  
 ![Capture d’écran 2022-12-26 145351](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/3/931bac7a4f66deec5c9983d635679108b1219f4f.jpeg)

Cordially  
christian.stan
