Python, Excel and Codeblocks

Hi everybody,
I am a new user of Dynamo.
I am trying to do some tests. What i have in my mind is this:

  1. i would like to use a python script that allow me to open an .xls file, extract some datas from a set of cells (i think i can do it with BUMBLEBEE).
  2. i already create a set of personal nodes (not in phyton, normal blocks codes), and i would like (i don’t know if its possible), when for example the cell value is A, then read the node that i already called A.
    I don’t know if its clear.
    I hope someone can suggets me something or other topics about this issue.
    Thanks in advance.
    Elisabetta

Hi @Elisabetta_Caterina ,
your request is not very clear… can you share any progress or attempts you made ?

Hi, don’t know if this is what you’re looking for.

  1. You can use both code block or Python to Import Excel File
    see the image below


.

if you want to read specific data cell
you can refer to this post to achieve.
Reading Excel files via Python script

.
2) you can first set many custom functions,
and then create a new Pass Function to filter,
and execute them by the specific name using the If Loop.
.
see the image below.
if the input is “A” or “B”,
then func_A will be called to draw a line, or func_B will be called to draw a circle;
otherwise will draw a point at (0,0,0)
.


.

I think it may be achieved by the similar way for Custom Nodes.

the attachments are the sample file.
ExcelandPassTest.dyn (10.1 KB)

ExcelandPassTest1.xls (24.5 KB)

.

1 Like

Thank you very much!
it is exactly what i was looking for.
many many thanks
Elisabetta

@zefreestijl many thanks again but actually i tried to check if i can convert my BlockCodes as you done.
But i have some problems.
My block is quite complicated. I think i made some syntax errors.
If i use it as Code Block, it works

but if i tried to use it as function, doesn’t work.

And the error is “The string is over-indexed” or something like that.

Actually i am not able to switch the language of the program in English.
@Konrad_K_Sobon I don’t know why but i tried three times to reinstall the program. But nothing, everytime i choose English and everytime is in Italian.
Thank you very much!
Elisabetta

Hi @Elisabetta_Caterina

I think the issue here is that you didn’t define the input “i” as a list.
try changing it to : def Fuction2b(i : var[],x,y,z)

@Mostafa_El_Ayoubi
I did it and now gave me ERROR ","
Elisabetta

@Elisabetta_Caterina
can you share your file ?

@Mostafa_El_Ayoubi
Data Pedestal.xlsx (21.9 KB)
VRIM_project_2.dyn (28.7 KB)
Thanks
Elisabetta

@Elisabetta_Caterina ok so I actually meant change the way you define the input i in the function .
And you had another problem here : the return value has an uppercase P whereas your variable has a lowercase p… :slight_smile:


If you change those two things it works fine.

You have a couple of lines in your code that don’t serve anypurpose but they don’t generate any error.
And finally, you give yout function a y input variable but set it to 0 inside the function, you may have a problem with that at some point…

1 Like

@Mostafa_El_Ayoubi
buahahahhaha i knew it was syntax :joy:
Thanks you very much. Four eyes are better than two :sweat_smile:

1 Like

glad I could help!

Hello everybody,
i still have some problems :slight_smile: I mean i am trying to use the @zefreestijl method by If Loop.
But my problem is that probably i have too many variables and i still not understand where i have to put them.
I done the Function Blocks with names.
Then i used the FuncPass
Maybe the problem are the too many Variables that i used for any function. Its seems like the FuncPass is not able to Read the 2b element.

The First List (Red One) is the List that i want to use to define the funcion that i want.
From the second list (Blue One) i would like to take informations.

So the thing that i would like to do is this:

Is if you Read 2b then Read the 2b Row and from 2b row take for example i[10] and i[20].

But because i have more than one 2b maybe the Loop is not working.
Many thanks
Elisabetta