Write sums element, insert them with Python into one list and to Excel

python

#1

I managed to write a python script to sum element of a list, than
insert the sum as a line into the list.
I checked on Online tutor python execution, also Anaconda and it worked.
When I pasted this script into python node I get some errors.
I surely misplaced something there .


It maybe something simple , so far I have not found the solution yet.
While the purpose is somehow silly, I think I can use this solution for other purposes as well If I get it right!

Working versions on Revit 2017 and Dynamo 1.2.1 3083
Any hint would be appreciated
I upload also the overall graph, a red circle indicates where I inserted the python node.
I tried also to read some design script instructions, but as I understood I needed

to go into imperative mode for changing lists. It helped me to understand more about Dynamo but I could not make it functioning thus I went back to Python.ListSumsandInsertelement.py (3.3 KB)
I uploaded also the python definition “standalone”…


#2

Please upload your Python code and/or dyn file and a sample rvt file to run it on.

Note that Dynamo only uses ironpyhon which is 2.7 so if you call modules or methods not in that version it won’t work.


#3

The warning states “float is not iterable” meaning that Python is expecting an iterable list and is receiving a single float instead. Check to make sure all your lists are structured correctly.


#4

Thanks. At the moment I had to leave the work as it is. I will come back. Since I cannot forward a file (it would be in Japanese btw) i will try to recreate the situation in a new file, maybe the Autodesk sample would work fine for this purpose.


#5

Hi @Uaifestival

There are many flavours of python like Cpython, Jython, Pypy, IronPython, Anaconda and many more .*ython. Each one has different syntax. Dynamo supports Iron Python you need to convert anaconda’s code to IronPython way. Cheers!


#6

Thanks, is not python 2.7 Iron Python the same? To my understanding, when I set everything to 2.7 (tutor and Anaconda as well, they can work with different versions) I should be ok.
Anyway I will do more research. I think my problem was more on tweaking the
way data are entering into the python node as it is slightly different than giving a list
prepared for debugging. It is just an hypothesis.