Grasshopper

algorithmic modeling for Rhino

I'm wondering if there is syntax to build an interval inside a function. For instance, I have a list and I want to remove the first and last items. I can do this with a handful of components (list length, subtract, build interval, subset), but it would keep things less crowded if I could just write an expression something like:

{1, x-2}

This gives me a 2-item list with the right numbers in it, but it isn't an interval, and is rejected by the SubSet component.

A script component would do the trick, but I'm trying to keep things simple...

Views: 450

Replies to This Discussion

You could use CullIndex and supply 0 and -1 as the indices (be sure to enable index wrapping).

But if you insist on using intervals then the syntax for an interval is:

"A To B"

Where A and B are any expressions that evaluate to numbers.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Incidentally,

{A, B}

is the notation for making Complex numbers if A and B are numeric and the notation for making a Plane if A and B are vectors or points.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you! Only one more question: how do I enable index wrapping (please pardon my ignorance). I right clicked and double clicked all over but haven't found it...
Sorry, my mistake. Index wrapping isn't available on CullIndex. Don't know why. I think it's supposed to be.... Anyway, I'll add it to the next version.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks for your efforts nonetheless. I decided to bite the proverbial bullet and wrote a little VB script to do it...here it is in case anyone else finds it useful:

Private Sub RunScript(ByVal x As List(Of OnLine), ByRef A As Object)
' Make the new list and a counter for the loop
Dim newList As New List(Of Online)
Dim i As Integer

'Lists are zero-based, so start at 1 and go until Count() - 2,
'adding the items to the new list
For i = 1 To x.Count() - 2
newList.Add(x(i))
Next

A = newList
End Sub

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service