Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

You don’t need to be a programmer to understand how to build a pricing script.
Using and modifying the example scripts is actually quite simple.

There are 3 four places in the software where pricing scripts can be used:

...

  • Preset Variables are available to be used for pricing

  • Both Mathematical Expressions and JavaScript Functions can be used in the Pricing Script

  • The Last Line of the script must output the final price

General Examples to Understand Pricing Concepts

In the most general case, the total price consists of three independent parts: material costs, machine costs and additional costs, such as labour, platform preparation cost, and so on. Naively, the formula can be written as follows:

Code Block
languagejs
let materialUsed;
let materialPrice;

let machineTime;
let hourlyRate;

let otherCosts;
let margin;

let price = (materialUsed*materialPrice + machineTime*hourlyRate + otherCosts)*(1
+ margin);

At the end of the formula, one needs to write the variable whose value should be returned. Typically, one ends the formula with price; written at the very bottom. If one want to check if the algorithm gives the correct value of other variables, e.g. of machine time, it is necessary to end the formula with the JS name of that variable (machineTime; in this case).

Info

These are general examples to explain the basic concepts of algorithmic pricing.
The respective pages (linked above) have more specific and realistic examples of pricing scripts.

...

...

Example Pricing Scripts to Illustrate Concepts

Table of Contents

Constant Pricing

If a fee or part should be priced the same for all users and for all orders, that can be input a single number into the script. Examples might be a fixed processing cost, a handling fee or a fixed price for internal prototyping in your company.

Code Block
languagejs
20.50  // default prototyping fee

Using Variables and Mathematical expressions

Each new variable must be defined with the keyword let. Then the variables can be used with normal arithmetic functions.

Code Block
languagejs
let a = 10 + 20;   // addition
let b = 30 - 5;    // subtraction
let c = 2 * 5;     // multiplication
let d = 10 / 2;    // division
let e = 10 ** 2    // exponentiation
a + b + c + d + e; // last line contains final price


Pre-defined Variables from Model Analysis

Depending on the algorithm type (Materials, Post-Processing, Order Fees), there are different sets of variables available within the platform. Those variables will fill in use value pulled from the uploaded and analyzed 3D model.

Code Block
languagejs
let cost1 = model.volume * 0.0002; // model.volume in cubic mm
let cost2 = model.area * 0.02;     // model.area in square mm
let price = cost1 + cost2;
price;                             // last line contains final price

Comparison and Relational operators

Name

Syntax

Examples

Equality

x == y

1 == 1; true
0 == 1; false

Inequality

x != y

1 != 2; true
1 != 1; false

Greater than operator

x > y

4 > 3; true

Greater than or equal operator

x >= y

4 >= 3; true
3 >= 3; true

Less than operator

x < y

3 < 4; true

Less than or equal operator

x <= y

3 <= 4; true
3 <= 3; true

Providing Conditions & Discounts

In order to offer competitive pricing, especially for larger orders or particular customer groups, the if/else functionality can adjust the price based on specific conditions. Additional support variables are available under User-based Pricing.

Code Block
languagejs
let price = model.volume * 0.0002;  // model.volume in cubic mm

// Add a 10% Discount when ordering more then 10 items
if(item.quantity > 10) {
    price = price * 0.90;
}

// Provide a 5% Discount for Users with a @3yourmind Address
else if(user.email && user.email.endsWith('@3yourmind.com')) {
    price = price * 0.95;
}

// 90$ Discount if price is above 1500
else if(price > 1500) {
    price = price - 90;
}

price; // last line contains final price

Accounting for Additional Costs

Additional costs that are generated by your business can also be accounted for, one of the most common being labor costs for preparing build platforms.

Code Block
let labor = ;                         // € or $
let platformPreparationCost = ;       // € or $

// platform preparation cost is calculated per part

let otherCosts = labor + platformPreparationCost/item.quantity;

Sample Complete Pricing Formula for FDM

Code Block
languagejs
//material cost
let materialPrice = 80;         // € or $
let materialDensity = 1.04;     // g/cm^3
let supportPrice = 80;          // €/kg or $/kg
let supportDensity = 1.04;      // g/cm^3
let infill = 0.2;               // number in [0,1]
let supportInfill = 0.2;        // number in [0,1]
let wallThickness = 2;          // mm

let materialUsedInfill = Math.max((model.volume - model.area * wallThickness) * infill, 0);
let materialUsedContour = Math.min(model.area * wallThickness, model.volume);
let materialUsed = materialUsedInfill + materialUsedContour;

let totalMaterialPrice = (materialUsed*materialDensity*materialPrice +
support.volume*supportPrice*supportDensity*supportInfill)*0.000001;

// hourly rate
let priceOfMachine = 200000;    // € or $
let usefulLife = 7;             // years  
let maintenance = 40000;        // € or $
let powerConsumption = 10000;   // €/year or $/year
let roomCost = 4000;            // €/year/m^2 or $/year/m^2
let space = 10;                 // m^2
let spareParts = 2000;          // €/year or $/year
let gasUsage = 0;               // €/year or $/year
let workingHoursPerYear = 3500; // hours/year

let hourlyRate = ((priceOfMachine + maintenance)/usefulLife + powerConsumption +
roomCost*space + spareParts + gasUsage)/workingHoursPerYear;

// machine time
let lineWidth = 0.1;      // mm
let layerHeight = 0.1;    // mm
let speed = 45;           // mm/s
let wallThickness = 2;    // mm

let volumeFactor = 0.0010747;
let areaFactor = 0.04317783;
let supportFactor = 0.0003774;

let exponent;
if( model.volume < 3000){
        exponent = 0.55;
} else {
        exponent = 0.88;
}

let volumePart = volumeFactor*(0.818182 - lineWidth)*(Math.pow(layerHeight, (-1.07)) +
0.232)*(Math.pow(speed, (-1.08)))*(Math.pow(infill*100, (1.02)))*model.volume;

let areaPart = areaFactor*(1.578431 - lineWidth)*(Math.pow(layerHeight, (-0.98)) + 0.341)*
(Math.pow(wallThickness, exponent) + 0.002)*(Math.pow(speed, (-0.84)) +
0.003)*model.area;

let supportPart = supportFactor*supportInfill*support.volume;

let time = volumePart + areaPart + supportPart;

let machineTime = time/60;

// other costs
let labour = 15;                      // € or $
let platformPreparationCost = 200;    // € or $

let otherCosts = labour + platformPreparationCost/item.quantity;

// final unit price
let margin = 0.1;

let price = (totalMaterialPrice + hourlyRate*machineTime + otherCosts)*(1+margin);
price;