Grasshopper

algorithmic modeling for Rhino

Hi guys,

I am looking for a way to wright a VB script which can unify two lists (similarly to the set union component in GH) with taking into account a Boolean condition .. Meaning that if the Boolean condition is true than set union -- else keep the original list as it is.

Btw it there a way to de this with GH components only ?

Thanks..

Views: 300

Replies to This Discussion

Sure, this can be done with native components.
In vb, assuming ListA, ListB and BooleanList have the same size, something like this:

Dim outList as new list(of datatype)

For i as int32 = 0 to ListA.Count - 1
   If BooleanList(i) then

      If Not outList.Contains(ListA(i)) then outList.add(ListA(i))

   Else

      outList.add(ListA(i))

   End if

Next

For i as int32 = 0 to ListB.Count - 1
   If BooleanList(i) then

      If Not outList.Contains(ListB(i)) then outList.add(ListB(i))

   Else

      outList.add(ListB(i))

   End if

Next

A = outList

I have not checked this code, so it can contain some error.

Thank you Daniel, I will have a look at the script .. I appreciate your help

How could it be done with native GH components ? the SUnion component does not contain a Boolean condition or a pattern ..

Well, maybe someone smarter than me can do it, I got tired of trying. It may not be possible, now I'm not sure, but it's simple from code, so... 

I think it could be done this way,

1- Test if there is an intersection between two lists of data.

2- If true then SUnion of the two original list

However I still need VB to introduce the Boolean condition, if x = true then y = U else y = empty ..

Maybe this is the way ..

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service