algorithmic modeling for Rhino
I am trying to create a Domain from a list of doubles. What I would like to do:
1. Take a list of doubles (representing point z-values) and break it down into it's domain components (min and max)
2. Extract the items (points) which are equal to the min and max values.
More than one suggestion is always helpful, as I am new to scripting, and need lots of food for thought.
Thanks!
Matt
Tags:
Hi Matt,
I assume this is a scripting exercise for its own sake? It can be done using standard components.
Finding the highest and lowest values in a list is something I usually solve as follows:
Dim min As Double = Double.MaxValue
Dim max As Double = Double.MinValue
Dim minIndex As Int32 = -1
Dim maxIndex As Int32 = -1
For i As Int32 = 0 To points.Count - 1
Dim z As Double = points(i).Z
If (z < min) Then
min = z
minIndex = i
End If
If (z > max) Then
max = z
maxIndex = i
End If
Next
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Yes, it is an exercise for the sake of scripting. I have done this with components (many many times) which is part of the reason I want to script it.
I would also be interested in developing domains and ranges, but I cannot find the namespace which houses these classes. Primarily, I would like the ability to grab values from a list, and also to develop values based on ranges.
Thank you for the examples.
Regards,
Matt
If you want to create a domain or interval, you can use either Rhino.Geometry.Interval or Grasshopper.Kernel.Types.GH_Interval. The GH_Interval merely wraps around the rhinocommon interval and makes sure that IGH_Goo is implemented. If you provide a Rhino.Geometry.Interval then Grasshopper will wrap it into a GH_Interval for you.
So at the end of the code above, you could add:
A = New Interval(min, max)
--
David Rutten
david@mcneel.com
Poprad, Slovakia
I will try this on the way home tonight. Thanks David.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by