sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Plugin] Get centroid and area properties for any face

    Scheduled Pinned Locked Moved Plugins
    12 Posts 11 Posters 18.0k Views 11 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      Nice contribution, thanks.

      Hi

      1 Reply Last reply Reply Quote 0
      • pbacotP Offline
        pbacot
        last edited by

        Curious, why do you need this? Are you using SU for structural analysis?

        MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

        1 Reply Last reply Reply Quote 0
        • W Offline
          watkins
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • alexschreyerA Offline
            alexschreyer Extension Creator
            last edited by

            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.

            Author of "Architectural Design with SketchUp":
            http://sketchupfordesign.com/

            1 Reply Last reply Reply Quote 0
            • B Offline
              bianhai
              last edited by

              A good work!
              thaks!alexschreyer. 👍

              1 Reply Last reply Reply Quote 0
              • MALAISEM Offline
                MALAISE
                last edited by

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

                MALAISE 👍 👍

                La Connaissance n'a de valeur que partagée

                1 Reply Last reply Reply Quote 0
                • S Offline
                  silver_shadow
                  last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • sumasterS Offline
                    sumaster
                    last edited by

                    Thank you . . . .

                    Thank you,
                    SUmaster

                    1 Reply Last reply Reply Quote 0
                    • fredo6F Offline
                      fredo6
                      last edited by

                      @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

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        glro
                        last edited by

                        @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

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement