[MaxScript] Get center position of specified faces

I’m wondering if there’s some way to get the center position of a set of specified faces, vertices or elements?

I know of one way to do it, which is to detach a duplicate of the selected faces, center the pivot, and then get it’s position. But it’s veeery slow. It would be awesome if I could somehow query the center position of specified components. Is this even possible to do with MaxScript?

Get the face vertices, add their positions together, divide by the number of the vertices - that’s your centerpoint.

Swordslayer’s method will get you the average position of the vertices that constitute the faces in question. For the center of the bounds of these vertices (if that’s of interest to you), you’ll need to get the min position and the max position of the vertex set and then calculate the median position:

p3_minPosition + P3_maxPosition / 2 – The min and the max position values contain the minimum x, y and z values and the maximum x, y and z values of the vertex set respectively. That is to say, for example, that the min x value may come from a different vert than the min y value.

doh, that was maya. ignore

Might be good to take advantage of some built in methods like polyop.getFaceCenter to optimize the calculations

http://help.autodesk.com/cloudhelp/2015/ENU/MAXScript-Help/files/GUID-B40F84EA-5F19-45B6-AA7C-0ADC77708BBE.htm#WS3ED54CBA79FF2E3D-417FC02312B7835BF26-6FC7