Hello,

Can anybody point me in the right direction regarding getting the centre points of objects and polygons in python.

Cinema4d has this built in (i.e. axis center, /points center) but i can't find it in the sdk or online.

I'm sure this must be fairly standard when manipulating geometry in Python and was wondering if anyone can provide any help on this topic

I just wrote a little script (for the polygon one) that selects a polygon index, and returns the four vector points in the list, and now I'm stuck, (mentally I could draw lines between the opposite vectors and where they intersect would( should) be the centre point of this polygon...

I've also been looking into centroid maths....

Any help would be much appreciated!

Thank you,

Simon

]]>Brilliant! Thank you very much, really appreciated!

]]>Oohh, right. Thanks, Niklas.

]]>The average point position is a different to the bounding-box center.

```
>>> values = [1, 2, 3, 42, 89, 1045]
\>>> sum(values) / float(len(values)) # Average
197.0
\>>> (min(values) + max(values)) / 2.0 # Center
523.0
```

Use BaseObject.GetMp() and BaseObject.GetRad().

-Niklas

]]>Yeah, averaging's how you do it, and you don't have to separate the xyz values, since dividing (or multiplying) a vector by a float/integer does that operation on all three.

]]>Update: Again if anyone has more information i'd appreciate it!

....but so far adding the vectors together then averaging them appears to be working, (I'm separating the averages into X, Y, Z and dividing by the number of points (4) on the polygon.

I'm going to try this approach for an object and try averaging all points (i.e. 8 on a cube) then will try irregular geometry...

Thanks for any help/advice!

]]>