THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/03/2010 at 15:20, xxxxxxxx wrote:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;
Ok my first post here
Let's say I select some points, and i want to set the position of an object in the center of the selected points, any idea with simple coffee script?
Here I attach image showing simple loop of points selected and placing a sphere in the center of the points
On 12/03/2010 at 17:53, xxxxxxxx wrote:
To get the center of of the points you will need to add the vector position of each point together and then divide by the number number of points. So you will need the average of all the points.
On 12/03/2010 at 18:49, xxxxxxxx wrote:
Right, yes, that makes lot of sense , thanks alot, but... how we do that in coffee?
On 13/03/2010 at 04:55, xxxxxxxx wrote:
Unfortunately I can't help you with the coffee syntax because I am not too familiar with COFFEE. I use C++ ... perhaps one of the COFFEE gurus here can jump in on this one.
On 14/03/2010 at 15:09, xxxxxxxx wrote:
How to know how many points are selected, with coffee, any idea?
using GetPointSelection? mmmm?
On 15/03/2010 at 03:03, xxxxxxxx wrote:
Here is some commented code building the average of selected points.
var op = doc->GetActiveObject(); //get selected object
//check if an object has been selected and if it is a polygon object
if (op && instanceof(op, PolygonObject))
var sel = op->GetPointSelection(); //get the point selection
var pcntsel = sel->GetCount(); //number of selected points
var points = op->GetPoints(); //get the points array
var pcnt = op->GetPointCount(); //number of points
var midpoint = vector(0.0);
var i = 0;
for (i = 0; i < pcnt; i++) //iterate through the selected points build the sum
midpoint += points[i];
if (pcntsel > 0)
midpoint /= pcntsel; //midpoint is the average of selected points