Hi.
I am trying to learn GH by recreating a Rhino-assignment we had at uni. The first steps of the assignment were to create a box and rotate 2 copies evenly spread on 360 degrees with the use of the _arraypolar command. The boxes should then be elevated so that the beginning corner of a box should be at the height of the end of the last.
In my attempt to re-create this in Grasshopper, I could not find an arraypolar-component, so I wrote one in c#. It works and places the boxes exactly where Rhino does, but as I am a newbie comments and improvements are welcome:
<code>
// define params
double numberOfCopies;
try
{
numberOfCopies = System.Convert.ToDouble(x); //check if input x was a number
}
catch (Exception e)
{
return; //if not break off execution
}
// if no number of copies are requested, abort
if(numberOfCopies <= 0)
return;
// create a list for the return of new angles
List<double> radian = new List <double>();
double divider; // use double in order to get double from division
for(int i = 1; i <= numberOfCopies; i++)
{
divider = i / (numberOfCopies + 1); // add 1 to the copies, in order to divide the copies evenly on the 360 degrees
radian.Add(divider * (2 * Math.PI)); // position along circle by 2pi to get radian
}
A = radian; // return list of radian
</code>
In the GH file I have set up an input that will set the number of copies and the return is a list of radian angles. This list is fed into a RotAx component which in turn creates an rotates the copies.
So far so good.
A problem I have is that I can't treat the output from the RotAx component individually. As you can see I want to elevate/move each copy of the box the height of the last. But as I have set it up it moves all copies to the same elevation. How can I set this up so that each copy is elevated higher?
Also, how can I delete the object that was moved, to avoid having the original and the elevated?
..
A further question is if this set-up is valid, or if there are better ways of achieving this?
Cheers,
Eirik
Tags:
- Attachments:
-