algorithmic modeling for Rhino
When I feed a list of list of points into GhPython, I find that the component detects what is being input, and will create the implied loops and output the result as a list of list of objects etc. They are "intelligent".
So my code in the GhPython is forced to operate on that sublist of points, rather than traverse the first list, then operate on that sublist of points.
Can I remove this "intelligence" so I can just work with the raw data?
Tags:
Hi Saeran,
You can right click on each component input and change the access to List Access. Then you will have the raw data to play with.
Mostapha
Hi Mostaph,
This works if I have a List of Points. Then choosing List Access gives me access to the entire list, and not just each point. However if I have nested lists, such as a List of List of pts i.e [[pt,pt1,pt2],[pt,pt1,pt2],[pt,pt1,pt2]] - I'm finding it's not giving me the 'global' list, just each sublist.
Any workaround for this?
Also thanks for LadyBug!
Saeran
Hi Saeran,
Check the attached example where I access the inputlist, sublists, and the items inside each list. If that's not what you are looking for then please upload an example.
No problem. Thank you for the kind comment. :)
Mostapha
You're right, it's working in the example you gave me - however in certain instances like when I'm using the Divide Surface component, the list of list of points is not giving me the full list access - even when I select 'List Access'. I've uploaded an example. If you go into the ghpython component and test the code, you can see it's only allowing access to the sublist, and not allowing me to access the entire list.
Hi Saeran! Is it still an open question or have you already figured it out? -Mostapha
Yes. Sorry, I've been busy on this end with school to really dig into it. But it's still an open question if you have any further advice.
In your example your input is a data tree (list of lists) and as Giulio and David said the component takes care of iterating over the lists. If you print the values you will only see the results for the last list.
If you want to have it all together you should change the access to tree access and read each branch in a loop and then read the items. See the attached file for a simple example.
Okay, so a list of lists is considered a DataTree?
Thank you for the example Mostapha, I played around with it and its exactly what I'm looking for. For anyone else looking into this, this post also helps with more information about the DataTree structure: http://www.grasshopper3d.com/forum/topics/datatreelistitem-access-from
A list that contains lists (that contain lists...) is a common way in Python to build matrices with two or more dimensions. However, this method does not precisely map to Grasshopper concepts. If the list of lists is built in a methodic way, in Grasshopper the same idea can be constructed with DataTrees.
Branches in DataTrees can be missing, while with lists of lists, the closest idea to obtain a gap is inserting a None item. They are similar, but slightly different concepts.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Hi Saeran,
adding just a little to what Mostapha said: it's not really the component being smart: this is how Grasshopper usually works. If you need any other type of 'implied loops', then just change 'Item Access' to 'List Access' or to 'Tree Access'. However, several algorithms are just much better to be left to Grasshopper: if you can, always use the simplest access type working for your script.
This is how I would develop a script, so it is suggestion. I hope this helps,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Solid advice. However if you must depart from Grasshopper standard ops, then you can wrap your data in a Grasshopper.Kernel.Types.GH_ObjectWrapper. At least the VB and C# components will detect that an output is already of type IGH_Goo and they won't attempt to parse the data any further. I'm not sure if Python does this as well, but Giulio did a pretty good job so it probably works.
--
David Rutten
david@mcneel.com
Thanks for the input, David. The current logic is in:
https://github.com/mcneel/ghpython/blob/master/Component/ComponentI...
please let me know if you spot anything unexpected. GH_ObjectWrapper is not mentioned, but it should not be treated unfairly, either.
Thanks,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by