sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Plugin] Center of Gravity

    Scheduled Pinned Locked Moved Plugins
    183 Posts 41 Posters 297.6k Views 41 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.
    • jojo9J Offline
      jojo9
      last edited by

      Great plugin! its possible to add some toolbar buttons? i tried but had no luck.

      #--------- menu -----------------------------
      unless file_loaded?(File.basename(__FILE__))
         txt0="C of G..."
         txt1="Find C of G"
         txt2="Composite C of G"
         dir=File.dirname(__FILE__)+"/TIGtools"
         toolname="CofGravity"
         locale=Sketchup.get_locale.upcase
         path=dir+"/"+toolname+locale+".lingvo"
         if File.exist?(path)
           txt0=deBabelizer(txt0,path)
           txt1=deBabelizer(txt1,path)
           txt2=deBabelizer(txt2,path)
         end#if
         submenu=UI.menu("Plugins").add_submenu(txt0)
         submenu.add_item(txt1){CofGravity.new(1)}
         submenu.add_item(txt2){CofGravity.new(2)}
         
      =begin   
        #plus
       	tb= UI.toolbar "Konstruktion"
       	
      	cmd = UI;;Command.new(txt1) {CofGravity.calculate}
      	cmd.small_icon = "../Images/Center_component_lg.png"
      	cmd.tooltip = "Teilmassen Zentrum"
      	tb.add_item(cmd)
      	
      	cmd1 = UI;;Command.new(txt2) {CofGravity.composite}
      	cmd1.small_icon = "../Images/Center_component_lg_sum.png"
      	cmd1.tooltip = "Hauptmassen Zentrum"
      	tb.add_item(cmd1)   
      =end  
      end#if
      file_loaded(File.basename(__FILE__))
      #---------------------------------
      

      sidenote. unable to format my text as code. I get a weird looking format table (please see attachment)

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        tb = UI.toolbar**.new**("Konstruktion")
        Makes the new toolbar.
        And use: cmd.small_icon = "Images/Center_component_lg.png"

        • assuming Images in in the same subfolder as the loading RB file ?
          You cannot add a new button to a existing toolbar unless you have just made it, OR if the toolbar has been made during the same start-up session AND it has an enduring reference...
          So in some earlier loading file [they load alphanumerically] use something like:
        module MY_STUFF
          ###
          TOOLBAR = UI.toolbar.new("Konstruktion")
          ###
        end
        

        Then in your second file: tb = MY_STUFF::TOOLBAR Which is an enduring reference to the 'MY_STUFF' toolbar entitled 'Konstruktion'...
        You can then add buttons to that toolbar as SketchUp starts - in any later loading script...

        TIG

        1 Reply Last reply Reply Quote 0
        • jojo9J Offline
          jojo9
          last edited by

          TIG, thanks for helping! i got it running, with another loader script, as you said.
          Furthermore, i corrected the call commands.

          1 Reply Last reply Reply Quote 0
          • PockocmocP Offline
            Pockocmoc
            last edited by

            Hi all, I am doing a 3D model in Sketchup 2016 and when trying to use CoG, it gives to me "weight=0.0"... How is it possible?

            Here is how I do :
            I create my 3D object, I select it and press "G" to save it as a single component. Then I select it, and I run CoG, applying a density of 7850 Kg/m3 (c40 steel density). It calculates during 5-6 minutes and finally shows 0.0 ...

            Any idea?

            Thanks!

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              Is it a 'Solid' object in Entity Info ?

              Without seeing the actual object and the settings you used I can't say what the issue might be.

              TIG

              1 Reply Last reply Reply Quote 0
              • PockocmocP Offline
                Pockocmoc
                last edited by

                Hi 😄 !

                Well, it seems it is not recognized as a solid, because there is no "volume" entry in the Entity Info box.

                Here is a picture :

                http://img15.hostingpics.net/pics/522313Prot3.png

                Thank you.

                Pock'

                1 Reply Last reply Reply Quote 0
                • PockocmocP Offline
                  Pockocmoc
                  last edited by

                  Oh, and even with a simple cube, (wich is solid) it does the same : no weight...

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    What version do you have ?
                    It should be v1.7 from the SketchUcation PluginStore ?
                    It's 3 years old but works on newer SketchUps anyway...

                    If you run it with the Ruby Console open are there any error messages ?

                    What settings are you using ?

                    What is getting reported exactly ?

                    Obviously the object's size versus the chosen density units can cause small objects to be reported as 0...
                    A small 'blade' probably needs to be in g/cm³ or similar...

                    Here's what I get with a component cube with protruding numerals [v2016].
                    It's a but over 1 m³ with a density of 2000 kg/m³ at the default 1% accuracy setting it returns a true volume in m³ and a weight in kg...
                    A much smaller [scaled] version reports '0' when the overly large units misapplied, but with g/cm³ it's fine...

                    Can you post a simple SKP that has issues so I can test it...


                    Capture.PNG


                    Capture1.PNG

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • BoxB Offline
                      Box
                      last edited by

                      It sounds like you may be creating component, but failing to tick the box that replaces the raw geometry with the component.
                      If there is no bounding box around your object it is just raw geometry, see if the component is in the component browser for you ready to use.

                      1 Reply Last reply Reply Quote 0
                      • PockocmocP Offline
                        Pockocmoc
                        last edited by

                        I am so stupid 😒 ... you are right TIG, it was because of the units, obviously! The blade weights 42 grams, so (0.0)42 Kg .

                        http://img15.hostingpics.net/pics/610277poidsnonmasse.png

                        Thank you for all.

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          hute_zhaw
                          last edited by

                          Hi Folks

                          I just installed this plugin into SketchUp 2017. It doesn't work as expected for me. The find CofG still works fine as far as I can tell but the Composit CofG returns a ruby error:

                          Error; #<TypeError; reference to deleted Group>
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;670;in `entities'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;670;in `block in do_composite'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;669;in `each'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;669;in `do_composite'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;117;in `initialize'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;817;in `new'
                          /Users/hute/Library/Application Support/SketchUp 2017/SketchUp/Plugins/CofGravity.rb;817;in `block in <top (required)>'
                          SketchUp;1;in `call'
                          

                          Has anybody got a clue how to fix this? It is really a pretty cool plugin and would be a shame if it became unusable.

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            Thanks for the bug-report.
                            I suspect that this is a glitch in the way v2017 handles exploded entities.
                            I'll investigate and fix it...

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              Here's v2.0 http://sketchucation.com/pluginstore?pln=CofG Its coding is now compatible with v2017 and it is also signed for use in v2016/v2017 in any loading-policy.

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • H Offline
                                hute_zhaw
                                last edited by

                                Outstanding work TIG, thanks that was quick, I can confirm it works after the upgrade of the plug-in.

                                Cheers

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  jbkbm
                                  last edited by

                                  The plugin does not seem to be able to detect hollow spaces. Am I doing something wrong? I am trying to find the CoG of steel assemblies but when it calculates the weight, it includes the space between plates and gives me a number much higher than the actual weight.
                                  http://imgur.com/a/bIITC

                                  1 Reply Last reply Reply Quote 0
                                  • TIGT Offline
                                    TIG Moderator
                                    last edited by

                                    Your image attachment isn't showing.
                                    An object needs to be a sensibly formed 'solid' - as reported in Entity Info.
                                    Otherwise results can be flaky...
                                    'Hollows' are accounted for, if it's a proper solid...

                                    If you attach your SKP we can look at it...

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • L Offline
                                      lsorrentino
                                      last edited by

                                      Hello All, hello TIG,
                                      I want to calculate the center of gravity of a small magnet, but the calculation always report volume = 0 and eventully weight = 0.

                                      The plugin works perfectly on my pc with larger objects, the density is 7.6 g/cm3, I'm a newbie with sketchup in general, I'm probably doing something wrong 😞

                                      Luca


                                      sketchup file


                                      screenshot


                                      result

                                      1 Reply Last reply Reply Quote 0
                                      • TIGT Offline
                                        TIG Moderator
                                        last edited by

                                        It must be a rounding issue.
                                        The object looks like it has no volume to SketchUp, therefore no weight.

                                        I'll investigate...

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by

                                          Yes, I see it.
                                          It was never intended for such small objects.
                                          It rounds to the nearest cu", so your small object appears to have no volume !
                                          I'll look at a way of adjusting it...

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • L Offline
                                            lsorrentino
                                            last edited by

                                            Wow, very interesting. Thank you very much!

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 6
                                            • 7
                                            • 8
                                            • 9
                                            • 10
                                            • 9 / 10
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement