Grasshopper

algorithmic modeling for Rhino

hi everyone,

I am new to python and I am trying to get my head around the its basic principles in relation to gh geometries.

I am having problems in defining lists of points to further use for line commands. as you can see from the pic, both my points_output contain a list of 3d points values. I created lists and appended those values to them but when I use the length list command, it gives me a value of 2??

what am I missing?

thanks in advance.

Fabio.

Views: 336

Replies to This Discussion

Hi Fabio,

What happens is that you are defining listP1/listP2 lists with a single item in them (points1/points2) where both of these have "None" value. Then to the same listP1/listP2 lists you add the points1/points2 lists. So basically your listP1/listP2 are now lists of lists, containing two items.


The rs.DivideCurve function already returns a list. So there's no need for you to append this returned list into a new list. If you still want to do that, use the "extend" function, instead of "append".

I would advice reading some python introduction material on lists, before going further with RhinoPython/grasshopper python.

thank you djordje. it begins to make a bit more sense. I will look into the introduction file for more info.

Be more confident instead of helpless, to be smarter. You are making silly mistakes as if they are set in stone instead of something to play with again and again, starting over from scratch until it works, and here you are using points1 just totally out of the blue before it exists as a variable, in a way that means you are not being resourceful, so what should take you minutes of playful work is taking hours online, as you assume something should work before even asking "where am I being silly here?" or "what can I quickly trial and error change?" Python is friendly and wants to work for you without a lot of crap going on you have to tweak, so have more faith in that, namely that you are breaking it by not appreciating how simple it is. So you are in complex debugging mode, unnecessarily.

Post away though, for there are no dumb questions when you are learning, since none of us knows how the brain works, especially in different people, but seeing you think outloud is rewarding in that I get reminded of how confused I was too, based on my temperament, so in a different way.

When working with RhinoPython, Python lists are a vital piece where you need to store a lot of data.
I used this guide https://likegeeks.com/python-list-functions/ to know many things about indexing, searching lists in Python.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service