Solid Weight

Hi

I’m working on a new product and would need to calculate the weight for some of the components.
If I remember correctly from my days with WinRhino there was a script by @dale which would calculate the weight of any solid. There was a lot of different material options built in. I think the script was called “Solid Weight.”
I remember having it on my Volume-button as a right click option. I haven’t had the need for it - until now - after I quit my day job (and WinRhino).
As I’m now working at home (MacRhino only) I don’t have the script anymore.
I wonder if @dale still have it - and perhaps we could have a Mac version of this nice tool? That would be really great :+1: It was such a convenient way to easily calculate the weight for different parts of a model.

Perhaps we could even have it as a native Rhino command (for both Windows and MacOS) - a right-click command for the Volume button :slightly_smiling_face:

Thanks in advance!

Philip

you can calculate the volume then multiply that by the weight of your material-

i think pascal cooked something up here you might have to look up the density of the material yourself though, i did not try it so dont whack me for pointing you into a possible dead end :smiley:

Sure, I know that :slightly_smiling_face: That old script was just so convenient - an (almost) one click solution. No maths involved :+1:

Philip

Thanks, I’ll take a look.

Philip

Well, Pascal’s script works, thanks @pascal! However… :slightly_smiling_face: I’d still like to have the same functionality as in Dale’s old script: select a solid -> push button (in my case I have it on the volume button as a right click) -> select material from a list -> the command finishes by printing the weight (in kg) on the command line.

I’m not sure how I could modify Pascal’s script to do this…

Any chance we could have a python script with this functionality (or a native Rhino command) @dale or @pascal?
Thank you!

Philip

Hi Philip - I’ll monkey with it… I’ve thought that doing this via render materials would be a good way - every render material has a Notes section that could contain a density note in a format that the script could read. Seems like that could be quite intuitive to use. A more geeky way would be to use object attribute text to assign a material density to an object.

-Pascal

1 Like

Hi @Philip,

See if this works for you:

SolidWeight.py (2.2 KB)

– Dale

1 Like

Hi Pascal! Yes, that sounds like a good and intuitive idea :+1: It would mean, though, that you would have to assign a material to the objects in question, which you probably not always would need to do (or would necessarily want to), but that wouldn’t be a serious drawback, I guess. However, it would have to work with any renderer - not just the inbuilt Rhino renderer/Cycles.
Thanks Pascal!

Philip

Hi Dale! Yes, thank you very much! That’s really perfect! :+1: I just need to add some common materials to the list, but I think I can manage to do that :slightly_smiling_face:
Thank you Dale!

Philip

1 Like

So where do I create the material density that pops up when running this PY? In the rendermaterials notes? How do I find that?

The materials and densities are hard coded in the script. You can edit it with any text editor to add additional materials.

-Kevin

Thanks Kev I’ll have a look. Anyone have a library with other than exotic jewelers materials?

I think I figured it out Kev and Pascal! My first venture into PY scripting! I added glass and titanium.SolidWeight JMC.py (2.3 KB)

Thanks guys!

1 Like

Hi guys! I made some additions to Dales python script. I found a list of common materials on my hard drive and added those (It might actually be the same list Dale had in his original Rhino script. I had the list on my Mac, but not the actual script itself)…
Anyway… I thought I’d share it, as it’s quite a nice, long material list, so it might be of some use to many of you.

Thanks again @dale - both for the python script and the old list! :slightly_smiling_face:

Philip

… and here’s the script:

SolidWeight_PK.py (5.3 KB)

Philip

1 Like

This is for @dale and @pascal - or anyone who knows the answers…
I wonder if I dare ask for one more thing (or two)… :wink: There are some things in the script I can’t figure out…

First little problem… Is it possible to make the script accept pre-selection of multiple items - and/or accept more than one post-selected object before popping up the list of materials? If a have a product with many parts of the same material it’s quite cumbersome to select the objects one by one, running the script many times and adding the results to get the total weight of, for instance, the metal parts in the product (a seat I’m working on at the moment has about 50 different steel parts).

Second problem… Is it possible to make the material list remember it’s size (also between sessions)? Now it always defaults back to the original size, which shows only a small part of the whole list.

One last thing (sorry)… When post-selecting, the selected object doesn’t highlight, so it’s not possible to be sure you selected the correct object (in a dense model) when the list pops up.

That’s it! Otherwise the script is perfect :+1: I really think it should be a native Rhino command.

Thank you very much in advance!

Philip

Thanks a lot for all this

I’m gonna try to add some gemstones and more precious metal alloys, but I have also a question @pascal. is there a way to allow for. range value? for example many gemstones range a little [Ruby = 3.97-4.05] or a lot [Opal = 1.88-2.50]

source: https://www.gemsociety.org/article/select-gems-ordered-density/

thanks a lot
Akash

1 Like

Having added some more precious metals to MetalWeight2AlloyAdded.py (2.7 KB)
I seems to have Created a small syntax error. and don’t know how to fix it.
Would someone please have a look.

@pascal could you please take a look when you have time?
it should be just like one syllable or space misplaced

And here’s a possible button for it if anyone wants. [for Dark and Light UI]

metal weight button light UI metal weight button dark UI

thanks a lot
Akash

Hi Akash - it looks like there is a mix of tabs & spaces in the indents - perhaps as a result of Copy/Paste - if you select your indented blocks of code in the editor and Shift-Tab until they are unindented right to the margin, the Tab over again, I think it will work -

-Pascal