algorithmic modeling for Rhino
Hi everybody!
Im having issues with creating an array of geometry objects. Out of a list of spheres I need to move every element by an increasing length. I tried the following thing:
for (int i = 0; i < spheres.Count; i++)
{
movevec = y.Direction;
fromp = y.From;
t = t + 0.1;
endp = y.PointAt(t);
moveline = new Line (fromp, endp);
movevec = moveline.Direction;
length = movevec.Length;
lengths.Add(length);
transform = spheres[i].Translate(movevec);
spheresm.Add(spheres[i]);
}
A = spheresm;
B = lengths;
I tried to make a translation vector inside a loop, which changes its length by every iteration step. The vector scaling is actually working, I checked that by adding the vector lengths to a list which i sent to B, and B shows me different vector lengths when I run the script.
For some reason though the translate method doesn´t do the job properly. Instead of moving the spheres by the actual movevector for every step of the loop, it just sums up the total of all lengths and moves all objects by the total.
As a result I get a list of spheres, located all in the same position instead of an array.
I would be very grateful for all helpful suggestions.
best
hjalmar
Tags:
Hi,
It would be good if you could attach the gh file cause I cannot replicate the code from these lines
one quick notice..
spheresm.Add(spheres[i]);
should be
spheresm.Add(transform);
Regards,
M.
Hi,
the thing is that the Translate method returns a boolean, therefore the transform variable is only a true/false value.
find the GH file attached
thx
H.
There seems to be a lot of code in that component that doesn't do anything. If you want to copy an object N times and move each copy a bit further, how about the attached?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
This works absolutely perfect! Thx a lot! I´m working actually on my first C# script, so I´m a bit lost sometimes...
regards
H.
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