algorithmic modeling for Rhino
Hey Everyone,
I am new to VB and I am trying to write something that will divide an angle in a particular way.
I have attached an image of an angle and some components that i was using to think through the problem. I have also attached the gh file.
1. I would like to have the inputs be an angle and a number of divisions.
2. Then i need to take the number of divisions and add one to it (example: # of Divisions = 4 so then the number we are actually dividing the angle by would be 5)
In this example the angle 83.53 is divided by 5 to give you a 16.706 angle.
3.Then the divided angle number gets divided by 2 (16.706/2=8.353)
4. The smaller angle number should always be the end angles and the other angles should be the larger number.
I need this to be recursive so that when the number of divisions changes you dont have to copy another rotate component.
I know this was probably a little unclear. I hope the attached file and image help.
I am not sure how to start writing this in a vb component.
If anyone could help me get started I would sincerely appreciate it.
Thanks,
Michelle
Tags:
I could also try to do this in python. I am currently trying to start both.
Hi Michelle!
I wrote:
Private Sub RunScript(ByVal angle As Double, ByVal n As Integer, ByRef A As Object)
Dim divAngle As Double = angle / (n + 1)
Dim angles As New List(Of Double)(n)
For i As Integer = 0 To n
angles.Add((i + 0.5) * divAngle)
Next
A = angles
End Sub
In the attached file you will find a second component which includes the bounding angles (0 and 83.53)
Greetings!
Thank you very much.
Dim angles As New List(Of Double)(n)
would you be able to tell me exactly what this line means?
Dim angles As New List(Of Double)
creates a new List of double values.
...(n)
specifies the initial capacity of the list. The list will grow automatically if you add more items but this will take a (very) little time. In this example you can drop it without problems.
(BTW: it has to be (n + 1). I got mixed up with VBs array declaration...)
I see thanks for the explanation!
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by