Object Cost > Script

 From:  stefano (LIGHTWAVE)
12020.1 
This is a quick utlity script
It uses object name as the 'calculator input'
Simply name objects as you would normally do,
then append the price at end after ">"

Example:
"YourObjectName>16.15"
anything after ">" is counted.

1 object selected = 16.15
10 objects selected = 161.15

8 objects selected:



Seems to work...ok..if any bugs or new requests or suggestions please provide feedback.

Other:
You can also set currency symbol in the code, or if currency copied to clipboard
or not. I prefer to choose "false" so: 129.90
you can change to "true" if you want to get $129.90.

code:
// ObjectCosts.js
// Calculates total cost from selected object names.
// Naming syntax: Material description >20.50
// Example: "Polycarb Clear 2mm >20.50"

(function(){

    var currency = "$";
    var copyCurrencySymbolToClipboard = false;

    function formatClipboardAmount( amount, currencySymbol, includeCurrencySymbol )
    {
        if ( includeCurrencySymbol )
            return currencySymbol + amount;

        return amount;
    }

    var objs = moi.geometryDatabase.getSelectedObjects();
    var total = 0;
    var found = 0;

    for ( var i = 0; i < objs.length; ++i )
    {
        var name = objs.item(i).name;
        var m = name.match(/> *([0-9]+(?:\.[0-9]{1,2})?)$/);

        if ( m )
        {
            total += parseFloat(m[1]);
            found++;
        }
    }

    var amount = total.toFixed(2);

    var clipboardText = formatClipboardAmount(
        amount,
        currency,
        copyCurrencySymbolToClipboard
    );

    moi.copyTextToClipboard( clipboardText );

    moi.ui.alert(
        "Found prices on " + found + " object(s)\n\n" +
        "Total = " + currency + amount + "\n\n" +
        "Copied to clipboard: " + clipboardText
    );

})();	


This script should go into usual place; moi app data commands folder and/or be assigned to a shortcut key
You can also use command line typing: "Objectcosts"

Resources:
Install scripts
Assign shortcut keys via options/shortcuts

EDITED: 12 Jun by LIGHTWAVE