algorithmic modeling for Rhino

Hi. Thank you

I wanna sorting lines through its angle. So, I used dictionary in python, and tried to make bundles consisted of curves which have same angle.

But, my ghpython showed a error message

"Runtime error (MissingMemberException): 'NoneType' object has no attribute 'append'"

I don't know how I fix it, and even I don't know what this message means. please help me.

Views: 261


Replies to This Discussion

you have an error because line 25 is incorrect, you need use 
dic_crvs[angs[i]] = dic_crvs[angs[i]].append(crvs[i]
but you also need change the logic of your code, because when you use set, you change the order of elements in list (set doesn't have an order), therefore angles and curves in lists not corresponding with each other. 

wow.. Thank you! it works.

So, if you okay, could you teach me why "dic_crvs[angs[i]] = dic_crvs[angs[i]].append(crvs[i])" is a wrong sentence?  

because "dic_crvs[angs[i]]" is a key of dictionary and when you write "dict[key]=..." it's mean that u want change a value for this key, not add new item to list. for example:
dict = {a:[1,2], b:[]}
dict[a] = [3]

your dict will be {a:[3], b:[]}

besides dic_crvs[angs[i]].append(crvs[i]) is not an item, if you print this, you will see "None", because it's like an action.

Thank you! I understand :-)






  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service