Skip to main content

Pricing worker examples

This article provides an example of pricing scripts.

Yordan Mitrev avatar
Written by Yordan Mitrev
Updated over 11 months ago

Guide to inputting the pricing script:

  1. Go to Autonomous > Worker Dashboard

  2. Create a new worker CREATE A NEW WORKER

  3. Select the Conditions

  4. Copy and paste this code in the code editor:

    1. # This block retrieves information 
      context = engine.getContext();
      engine.modelVersionFieldsResolve(context.modelVersionId, []);
      modelVersion = engine.modelVersionRetrieve({'id': context.modelVersionId});
      productionParameters = context.productionParameters


      # return file parameters in mm^3
      width = float(modelVersion.width)
      height = float(modelVersion.height)
      depth = float(modelVersion.depth)
      surface_area = float(modelVersion.surface)
      bounding_box_volume = float(width*height*depth)
      volume = float(modelVersion.volume)


      # return production parameters
      quantity = int(productionParameters.Quantity)

      def get_production_time():
      production_time = context.productionParameters['Production Time']
      return production_time


      # calculation logic
      factor_1 = height*volume/1000
      factor_2 = surface_area/1000 / bounding_box_volume/1000/1000


      # Set price
      price = factor_2 + factor_1




      # This updates the price when assigning production parameters
      engine.updateResponse({
      'price': price,
      'priceToken': context.priceToken,
      })
  5. This code uses:

    • File parameters (volume / dimensions)

    • Production parameters (inputted in the quotation form)

  6. Using these variables, you can create a custom script to price parts.

Did this answer your question?