Grasshopper

algorithmic modeling for Rhino

Hello again,

So I have a list of vectors that were created by using the "vector b/w 2 pts" component. Some values are null because there is no distance between the two points. In order to have the Vector list comply with an equal numbered list of Points, I need to replace the null items in the Vector list with a Zero value. Is this possible or is there another way around this? Thanks for the help

Ben

Views: 14899

Replies to This Discussion

Not sure if this is the most efficient way but it does achieve the desired effect.
1) Identify the Null Items [Logic>List>Null Item]
2) Create a SERIES numbering 0 to n, where n is the list length
3) Dispatch both lists equally using the boolean pattern from the Null Items
4) Generate the right number of ZEROs to replace the NULLs
5) MERGE each dispatched list together so that the ZEROs are tagged on the end (similar with the indices)
6) Sort the Indices List and Synchronously sort the original Merged list
7) Simplify tree (same as original structure)


A Similar approach can be taken to find a specific value and then replace eg find 0 and replace with 0.1


NB the graft tree component is redundant since I flattened the inputs to the Merge component.
Thanks a million. Worked great

Hi Danny,

Is there a way to do this with a branched list?

Struggling to adapt it or come up with a simple alternative...

Many thanks,

Arthur

Hi Arthur,

This is how I would approach replacing Nulls now. The key change is that since 2009!!! the List Replace Component has come along.

Danny

Thanks a lot Danny, very helpful as always!

Hello from Tel Aviv :) 

Hi Danny, I am working through a similar problem, trying to replace all null values with 0 values. I am following the method you are showing, but it falls apart at sort list. Can you attach the definition file? Thank you!

Hi Arpan,

have a look at my reply to Arthur in February of this year (2012 for the benefit of future searches) 

Couldn't find it ... do you have a title or link?

THX

OMG you have to do such convoluted crap just to what in C# would be: RemoveUnsucessfulFeatures().
Flawed. And crap.

John, from the look of RemoveUnsuccessfulFeatures(), it would remove all null items. But what would be the function for "Replace" UnsuccessfulFeatures with ___ value.

There is no such method in RhinoCommon or Grasshopper. Of course if someone goes through the trouble of writing it you can just call it. Similarly, if someone goes through the trouble of making a component for it (just did!) you can also just use that.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

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