Object Cost > Script

Next
 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


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
12020.2 
About € against $ i suppose just to edit the file or it's more complicated ?
---
Pilou
Is beautiful that please without concept!
My Moi French Site
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  stefano (LIGHTWAVE)
12020.3 In reply to 12020.2 
hi pilou, yes that should work, let me know if it does not work as intented
or you want any other tweaks.. cheers stefano
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
12020.4 In reply to 12020.3 
This is a clever idea Stefano, thanks for sharing!

I've also appreciated your CommandPalette, though have only been using v1.20 as it met my needs.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  stefano (LIGHTWAVE)
12020.5 In reply to 12020.4 
cheers for the feedback Larry,

i also like the one off scripts, the other one im using (a lot) is the curvelengths one i posted
few weeks or so ago (i think). i'll likely do a better modal window one soon...

re: command palette glad you getting some use out of it.

cheers stefano
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All