THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/06/2006 at 05:08, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1+
Platform: Windows ; Mac OSX ;
Language(s) : C.O.F.F.E.E ;
---------
I need some help understanding using arrays.
What I'd like to do is using the selected points in a PointSelectionTag.
Add those points positions and divide by the amount of points to get a mid position.
I come as far as the code below, I get the indexes and corresponding positions,but cannot get the grips of using an array to store and calculate them.
Given that the result allready is an array, as it looks, I might be on the wrong track, maybe.....
I -assume- I'll have to use an array for this, if not is there a better way?
Cheers
Lennart
main(doc,op)
{
var link = op#ID_USERDATA:1; // A object in a linkfield
if(link->IsInstanceOf(Tpointselection) !=FALSE) // If it is a PointSelectionTag run
{
println("YES"); // It´s a pointselectionTag
}
else
{
println("NO");
return;
}
// Get the selected points , index and position
var pointsel = link->GetSelection(); // get whats stored in the Tag
var count = link->GetObject()->GetPointCount(); // get the amount of points in the object
var i=0;
var found=0;
for (i=0; i< count; i++)
{
if(pointsel->IsSelected(i))
{
found++;
println(link->GetObject()->GetPoint(i)); // Prints the selected points position(s) as an array
println(i); // print the indexes of the points
println(found); // prints the amount of selected points
/*
Here I need to add all selected points positions and divide by found to get the avarage position
*/
}
}
}