Model weight by density (Meshes and Polysurfs)

Hi
I took as a basis the script on by Paul Finelt. This script seemed to me elegant.
I sent him an invitation to this discussion.

And for convenience, I simplified it a bit.
But unfortunately this script did not initially count the weight of the meshes.
I added arrObjects = Rhino.GetObjects + 32
And tried to play with Rhino.IsMesh (strObject) and Rhino.IsMesh (arrObject)
But it was not a success.

If interrupt the execution of the script after the appearance of the table “Weight Selection” (Esc or Cancel), then an error appears with “UBound” Line 92, Char 1, How to remove this error?

Initially, the script gives an analysis for only one model. I would like to redo it to weigh several models at the same time.

Can anyone help bring this script to perfection?

Thanks

Modified_ItemWeightPF.rvb (3.8 KB)
pfa.ini (641 Bytes)