Grasshopper

algorithmic modeling for Rhino

I am using the anemone iteration tool to loop through a series of parameters that I use to do some calculations. 

In the example I have attached I have a list of numbers that I want to loop through to find the number 9 in the list.  The time buffer has been added to emulate the delay that might be encountered if the VB program was doing some complex calculation.

With a delay set to 90 ms, the iteration stops when it encounters the first occurrence of the number 9.

when this is increased to 100 ms, it becomes rather random.  Sometimes it stops at the second occurrence of the number 9 or it never finds it.

How do I modify the script so that it always finds the first occurrence of the 9 regardless of the delay parameter.

Many thanks

Views: 4443

Attachments:

Replies to This Discussion

Do you just need to find the index of the first occurance of 9? If yes, use [Member Index] from the Sets>Sets tab, plus a [List Item].

The search for the first occurrence of the number 9 is just a simplified version of the task that I need to do.  In reality the list of numbers on the left is fed into a complex set of calculations, the results from which is used to determine whether to proceed with the iteration.

Wait a minute - I looked again, and I think you are only allowed/supposed to connect the [Time Buffer] between Anemone's Data Out/Inputs  (D0, D1, D2,...),  and not to the E (Exit) Input. Is that it?

Attachments:

I will implement this modification to my script and get back to you.  Thank you

I see, then I don't know (what to say). Too abstract to follow for me.

You're saying

The time buffer has been added to emulate the delay that might be encountered if the VB program was doing some complex calculation.

By default the Time Buffer is working in a bit different way than that.

There are two options to fix your issue, I'm not totally sure about the second one. 

Option 1.

The Time buffer has to be directly connected to any of the D inputs of the Loop End. You can add an additional input if you need. It'll hold the data and prevent the Loop End from sending it back to the Loop Start. If there is anything in between (even a component producing a null value), it will still provide the Loop End with some value (null), and will trigger the next iteration.

Option 2. 

Switch the Time Buffer to regular mode. By default it is Multithreaded, which means it let's GH do whatever GH wants while it holds the data internally. This will force the current thread in which GH works to Sleep for the specified time. That way you're actually getting what you want in your description (simulating some long process)... unless you're already doing that (no visual indication to deduct that, my fault).

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