How i calcule weight of an object or solid, have solution easy?

Most of the necessary capability is in the Ruby API. If you are willing to type a couple of lines into the Ruby Console Window, it is actually a very simple bit of code.

  1. in the Ruby Console input panel (the part at the bottom), type:
density = 2.54

where you should replace 2.54 with the density of whatever material you are using
2. Select a solid in the model
3. In the Ruby Console input panel type:

Sketchup.active_model.selection[0].volume * density

The calculated value will be displayed in the Ruby Console results panel (the top part of the window). If you get a negative value or an error message, the object you selected isn’t a SketchUp solid.

Edit: the Ruby API uses SketchUp’s internal units of inches, so even if you have units set to metric in your model info, the API volume will be in cubic inches and your density will likewise have to be in mass/cubic inch. It is possible to work around this, but it requires some more lines of code.

1 Like