Solid Weight

Thanks Pascal
I did as you said, and these + - are gone now. But now the error has gone up to line 8. …?
here’s the Shift+Tabed script
MetalWeight2AlloyAdded_E01.py (2.6 KB)

Fixed.
MetalWeight2AlloyAdded_E02.py (2.7 KB)

Yes thanks a lot @inju .

it works now.

Best regards
Akash

1 Like

Hi
I’m trying to adept SolidWeight.py (11 Bytes)
to be used with gem stones,
And there are 2 calculation issue I believe are inside the part at the end of the script: the conversion area.

scale = rs.UnitScale(3)
volume = volume * (scale ** 3)
print("Volume = {:.3f} cubic centimeters".format(volume))

# Calculate the weight in grams
weight = volume * density
print("Weight = {:.3f} grams".format(weight))
  1. issue I see is that there is one extra 0 in the results.
    [at least while working in mm. file template]
  2. And then for gemstone the weight results need to be in Carats not in Grams.
    1g = 5 carats.

With many thanks
Akash

New to python
I just tried the solidweight.py, why does the script use cubic centimeters and not (units=modelUnits)

I just found why

Convert volume to cubic centimeters

scale = rs.UnitScale(3)
volume = volume * (scale ** 3)
print("Volume = {:.3f} cubic centimeters".format(volume))

@Eddyf, when I wrote the original sample script (many, many years ago), this is the unit system requested by the user. Obviously, you can modify the script to do whatever…

– Dale

thanks
I’m playing now

Hi Dale
I’m trying to modify the values for MM and Carats.
I get either too high [by order of magnitude ] values or too low… Obviously I have no idea what I’m doing [python and mathematically wise] .

This is a very useful script for calculating the weight of gemstones so can be useful to many jewellery modellers here

thanks a lot
Akash

Here’s an adjustment on Dale’s SolidWeight script.
It prints gemstones weight in Carats.
I entered many gemstones [not in any meaningful order], and did and average density for most of them, as usually there is a density range.

It would have be better to print the range, but that will requires someone how knows how to script to get it done.
tool button is for dark skin, but can easily be inverted if any one wants to use it.

GemWeight version of SolidWeight.py (4.3 KB)
GemWeight button

Akash

Here trying to add another small modification to the slightly modified original SolidWeight script GemWeight.py (4.3 KB) Trying to make it work also with SubD.
I’m guessing what is missing is in here:

filter = 8 + 16 + 32 # surface, polysrf, mesh, subD
obj_id = rs.GetObject(“Select solid surface, polysurface, subD, or mesh”, filter)
if not obj_id:
return
if not rs.IsObjectSolid(obj_id):

With Thanks
akash