Changes in Python?


#1

Hi

I would like to ask if there are some changes in Python in Dynamo 0.8 and 0.9 compared to 0.75.

I have a script which worked just fine in 0.75 but doesn’t work in 0.8 and 0.9


#2

Couple of things:

 

  1. You open a Transaction but never commit it. Please make sure that you close a transaction at the end of your script.
  2. Your inputs E and N. If they are lists, then this method doesn't work for unwrapping them. What it does, it unwraps a whole list into a list object.
 

Check those out.


#3

Technically UnwrapElement does work on lists but with one major drawback - the output is not a python list object. It says it’s a list but it behaves as a tuple:

 

 

 

 

 

 

 

 

 

 

If I try to append something, l2 fails:

Dynamo_2016-01-14_11-50-24

 

 

 

 

 

 

 


#4

Thank you both for your suggestions. Are there any changes in the API though? I still can’t make it run. I am trying to join multiple objects to a single one.

join

join


#5

When I said that you can’t unwrap a list of elements like that i didn’t mean that you don’t have to unwrap them at all. you do. just iterate through the list:

if isinstance(IN[0], list):

unwrappedList = [UnwrapElement(i) for i in IN[0] ]

else:

unwrappedList = [UnwrapElement(IN[0])]

 

that’s for a flat list. if you have a nested list of elements, you would need a function and then map over it.

Dimitar,

Yes, that’s what I meant. It unwraps the whole thing into a single object that is not a Python list. :slight_smile:


#6

Thanks.

I’ll give it a try. I’m pretty sure though that previously I’ve used this same piece of Python script successfully using lists as imports.