Grasshopper

algorithmic modeling for Rhino

I am trying to find the index of the first value in M_Rd which is bigger than the bending moment on the left. Any suggestions on how to solve this?

Thanks,

Rasmus

Views: 852

Replies to This Discussion

Hi.

Check this. Best.

Thanks a lot.

For some reason the Member index does not return an index. It seems like there is something wrong with the datatype coming out of the List item... If I manually write the value I am searching for in a panel the index is return correctly, but the way it is set up at the moment does not return the index.

How about this?

Attachments:

Never mind. I solved it.

But thanks again! :)

Hello,

this could be a way too

best

alex

When you say "the index of the first value in M_Rd which is bigger", I thought you meant index of first item in the list that is bigger?  So for your example, the index would be 1 and the value=70.68?

Or did you mean index of smallest value which is bigger, as Hyungsoo Kim did it?

In other words, while it does affect the index if you reverse the list, does the sequence of the M_Rd list affect the value?

Here is a slightly different arrangement of Hyungsoo Kim's code - same result:

This code depends on the sequence of the 'M_Rd' data, returning the index of first item in the list (in sequence!) that is bigger.  Reverse the list and get a different result:

Attachments:

Here's a simple solution using GHPython (that might be faster on large data sets, since you can break out of the loop as soon as you get the first value that is is larger than the bending moment):

Attachments:

It looks like you interpreted the problem as I did - find the first value in the sequence that is larger rather than the smallest value that is larger.  I hope the OP (Rasmus Bendtsen) will clarify his intention, and perhaps post his solution?

Your Python code initially failed for me when I applied the data I used in previous post.  Appears to be a data type problem as I was able to fix it by running the 'X' value through a 'Num' param:

Attachments:

Ah yeah, I think I didn't explicitly set type hints, so the data will be passed as a string when coming from a Panel (just right-click the input parameters and set them to float to fix).

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