[Plugin] Get centroid and area properties for any face

[Plugin] Get centroid and area properties for any face

Postby alexschreyer » Sat Oct 11, 2008 7:13 pm

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/
0
Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
User avatar
alexschreyer 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Get centroid and area properties for any face

Postby Whaat » Sat Oct 11, 2008 7:59 pm

Thanks! I was needing a plugin like this. Do you happen to have a reference for the mathematical methods you used?
0

Whaat 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Get centroid and area properties for any face

Postby Jim » Sat Oct 11, 2008 8:05 pm

Nice contribution, thanks.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin] Get centroid and area properties for any face

Postby pbacot » Sat Oct 11, 2008 8:46 pm

Curious, why do you need this? Are you using SU for structural analysis?
0
MacOSX (El Capitan) ShetchUp Pro v16 Layout Twilight Pro v2 M2 Kerkythea PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: [Plugin] Get centroid and area properties for any face

Postby watkins » Sat Oct 11, 2008 9:33 pm

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, 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
0

watkins 
 

Re: [Plugin] Get centroid and area properties for any face

Postby alexschreyer » Sun Oct 12, 2008 2:23 am

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.
0
Author of "Architectural Design with SketchUp":
http://sketchupfordesign.com/
User avatar
alexschreyer 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Get centroid and area properties for any face

Postby bianhai » Sun Oct 12, 2008 6:17 am

A good work!
thaks!alexschreyer. :thumb:
0

bianhai 
Banned
 

Re: [Plugin] Get centroid and area properties for any face

Postby MALAISE » Sun Oct 12, 2008 7:19 am

Very interesting Plugin. So we can also make rotation with complex form.

MALAISE :thumb: :thumb:
0
La Connaissance n'a de valeur que partagée
User avatar
MALAISE 
 

Re: [Plugin] Get centroid and area properties for any face

Postby silver_shadow » Tue Oct 14, 2008 7:06 am

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 plugin

found 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!!)
0

silver_shadow 
 

Re: [Plugin] Get centroid and area properties for any face

Postby sumaster » Sun Sep 23, 2012 4:58 pm

Thank you . . . .
0
Thank you,
SUmaster
User avatar
sumaster 
 

Re: [Plugin] Get centroid and area properties for any face

Postby fredo6 » Mon Sep 24, 2012 9:26 pm

Whaat wrote: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

Code: Select all
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
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Get centroid and area properties for any face

Postby glro » Tue Aug 19, 2014 10:55 am

alexschreyer wrote: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= ]http://www.skpengineering.com[/anchor] is not avalaible anymore
0

glro 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: AntBM, Bing [Bot], Debora Macedo, Google Bot, ljus, ngoctung0211, userid7 and 11 guests

Visit our sponsors: