A little while ago, I had a need for calculating centroids for planar shapes. To be more exact, my students had the need since I gave them an assignment that required this. Not knowing of a plugin for SketchUp that would accomplish this feat, they did it in Rhino or AutoCAD instead.
To rid SketchUp of this shortcoming, I decided to re-use some old Pascal code of mine and try my hand at writing a plugin for this. Here is now the result.
This plugin will calculate area properties for planar shapes. These shapes must be drawn on the X-Y plane (the ground plane) in SketchUp. Of course these shapes must be closed so that a single face is generated by SketchUp.
To calculate area properties, select one or more of these shapes and either choose “Get Face Centroid” from the Tools menu or the right-click context menu. The plugin will then calculate area properties for each face successively. These (area and moments Ix, Iy, Ixy) will then be displayed in a dialog that allows for copying of values. As final step, a construction point and a set of X-Y axes will be drawn at the area centroid. See the image below for details:
Screenshot of GetCentroid.rb SketchUp Plugin
There are other plugins available that use a similar concept and draw a centerpoint. This is usually done for the center of the bounding box, which only in the case of a rectangle coincides with the area centroid. One example is the CenterPoint plugin available on Smustard.
Please note also that the accuracy of the calculations is dependent on the accuracy of the polygonal shape. While SketchUp draws lines accurately, curves are always approximated by a polyline.