[Plugin] Get centroid and area properties for any face
-
I ran into a problem a while ago where I needed area centroids of irregular planar shapes. Since I couldn't find an appropriate SketchUp plugin, I used Rhino that time. The attached plugin adds this functionality to SketchUp.
Contrary to some plugins that I found, which use the centroid of the bounding box (and then add a construction point there), this one calculates the actual centroid accurately for any polygon (hence any shape in SketchUp). It also provides the area (more for reference since SketchUp spits this out anyways) and the area moments Ix, Iy, Ixy.
Please give this a try and let me know if you run into any usability, calculation or proper plugin programming issues.
Some limitations: Shapes must be drawn on the ground (x-y plane) and calculation accuracy is limited by polygon accuracy.
Plugin webpage (available soon): http://www.alexschreyer.net/projects/centroid-and-area-properties-plugin-for-sketchup/
-
Thanks! I was needing a plugin like this. Do you happen to have a reference for the mathematical methods you used?
-
Nice contribution, thanks.
-
Curious, why do you need this? Are you using SU for structural analysis?
-
Dear Alex,
Perhaps you and TIG could get together and combine your scripts so that the C-of-G and moments of inertia of a complex shape could be calculated. TIG's script (VolumeCalculator, http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=1532&hilit=+Plugin)calculates the volume by slicing up the shape into wafers parallel to the X-Y plane. The script could be extended to include a look-up table of the densities of typical building materials to yield the mass of the shape (concrete slab, say). If the table of densities could be edited by the user to add/remove materials then that would be even better.
Just a suggestion,
Kind regards,
Bob -
Thanks all for the comments. Some replies:
I needed this functionality because I got my students to design and make mobiles as a fun example of small "structures". It might be useful for designing cross sections for structural analysis or for finding load resultant locations, too.
I'll check where I got the formulas from. It was some structural reference book. I actually re-used some old Pascal code here.
I bet there's a generalized 3d variant of this calculation approach. Haven't looked into it yet. I would think, though, that vertice ordering would be a major issue there.
-
A good work!
thaks!alexschreyer. -
Very interesting Plugin. So we can also make rotation with complex form.
MALAISE
-
hi there, pretty cool plugin.
Is there a way you can make another one for a calculation of square metres?
The current calculation is square ft.
pretty please... really nice pluginfound only one bug: if i move the face away from the axis,calcultate the centre,...the centre drops to the axis. can you maybe fix it so it witt stay on the face. Thanx (HI 5 dude!!)
-
Thank you . . . .
-
@whaat said:
Thanks! I was needing a plugin like this. Do you happen to have a reference for the mathematical methods you used?
The method is fairly simple and actually computes the area of the face
def self.face_centroid(face) lpt = face.outer_loop.vertices.collect { |v| v.position } axes = face.normal.axes tr_axe = Geom;;Transformation.axes lpt[0], axes[0], axes[1], axes[2] tr_axe_inv = tr_axe.inverse lpt = lpt.collect { |pt| tr_axe_inv * pt } lpt.push lpt[0] area = 0.0 cx = cy = 0 for i in 0..lpt.length-2 pt1 = lpt[i] pt2 = lpt[i+1] a = pt1.x * pt2.y - pt2.x * pt1.y area += a cx += (pt1.x + pt2.x) * a cy += (pt1.y + pt2.y) * a end area *= 3 tr_axe * Geom;;Point3d.new(cx / area, cy / area, 0) end
This is what I used in FredoTools::ConstructFaceNormal, which draw the normal to any face at its centroid
Fredo
-
@alexschreyer said:
I ran into a problem a while ago where I needed area centroids of irregular planar shapes. Since I couldn't find an appropriate SketchUp plugin, I used Rhino that time. The attached plugin adds this functionality to SketchUp.
Contrary to some plugins that I found, which use the centroid of the bounding box (and then add a construction point there), this one calculates the actual centroid accurately for any polygon (hence any shape in SketchUp). It also provides the area (more for reference since SketchUp spits this out anyways) and the area moments Ix, Iy, Ixy.
Please give this a try and let me know if you run into any usability, calculation or proper plugin programming issues.
Some limitations: Shapes must be drawn on the ground (x-y plane) and calculation accuracy is limited by polygon accuracy.
Plugin webpage (available soon): http://www.alexschreyer.net/projects/centroid-and-area-properties-plugin-for-sketchup/
plastic characteristics of cross sections are sometimes needed too...
is it something that could be added to the plugin? because [anchor= goto=:1n1fsrz0]http://www.skpengineering.com[/anchor:1n1fsrz0] is not avalaible anymore
Advertisement