Trigger an optimization

Prev Next

For: Integrators · Partners

This page describes steps 1 to 3 of the cutting optimization workflow: determine configuration, create an optimization, and monitor progress. The examples show the SDK call and the corresponding REST call with its response.

For the C# examples, assume you have initialized a client:

using HomagConnect.IntelliDivide.Client;
using HomagConnect.IntelliDivide.Contracts;
using HomagConnect.IntelliDivide.Contracts.Common;
using HomagConnect.IntelliDivide.Contracts.Request;

var intelliDivide = new IntelliDivideClient(subscriptionId, authorizationKey);

1. Determine the configuration

Before creating an optimization, query which machines and parameter sets are available in the subscription. This lets your integration build selection lists and default values dynamically instead of hard-coding values that might change for the customer. These fields are described by the OptimizationMachine and OptimizationParameter contracts.

// Check whether the configured machine exists
const string machineName = "productionAssist Cutting";

var machine = await intelliDivide.GetMachine(machineName);

if (machine == null)
{
    throw new InvalidOperationException($"Die Maschine '{machineName}' wurde nicht gefunden.");
}

// Check whether the configured parameter set exists
const string parameterSetName = "Boards only";

var parameters = await intelliDivide.GetParameters(OptimizationType.Cutting);
var parameterSet = parameters?.FirstOrDefault(p => p.Name == parameterSetName);

if (parameterSet == null)
{
    throw new InvalidOperationException($"Der Parametersatz '{parameterSetName}' wurde nicht gefunden.");
}
# Find the machine by name
GET /api/intelliDivide/machines?machineName=productionAssist%20Cutting

200 OK
Content-Type: application/json

[
  {
    "name": "productionAssist Cutting",
    "optimizationType": "Cutting"
  }
]

# Get parameter sets for cutting
GET /api/intelliDivide/Cutting/parameters

200 OK
Content-Type: application/json

[
  {
    "name": "Boards only",
    "optimizationType": "Cutting"
  }
]

Tip: The material codes known to intelliDivide are returned by GetBoardTypes(take, skip) or GET /api/intelliDivide/materials/boards?take=…&skip=…. Use this to validate your codes before submitting parts.

2. Create an optimization

Submit the part list along with the machine and parameter set. This creates an optimization in the New state (see OptimizationStatus). The body follows the OptimizationRequest contract; each part follows the OptimizationRequestPart contract.

Create an optimization

var request = new OptimizationRequest
{
    Name = "Auftrag 4711 – Korpusteile",
    Machine = machineName,
    Parameters = parameterSetName
};

request.Parts.Add(new OptimizationRequestPart
{
    Description = "Seitenwand",
    MaterialCode = "P2_White_19.0",
    Length = 720,
    Width = 560,
    Quantity = 10
});

request.Parts.Add(new OptimizationRequestPart
{
    Description = "Fachboden",
    MaterialCode = "P2_White_19.0",
    Length = 564,
    Width = 540,
    Quantity = 20
});

var response = await intelliDivide.RequestOptimization(request);
POST /api/intelliDivide/optimizations
Content-Type: multipart/form-data

optimizationRequest:
{
  "name": "Auftrag 4711 – Korpusteile",
  "machine": "productionAssist Cutting",
  "parameters": "Boards only",
  "parts": [
    { "description": "Seitenwand", "materialCode": "P2_White_19.0", "length": 720, "width": 560, "quantity": 10 },
    { "description": "Fachboden",  "materialCode": "P2_White_19.0", "length": 564, "width": 540, "quantity": 20 }
  ]
}

200 OK
Content-Type: application/json

{
  "optimizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "optimizationStatus": "New",
  "link": "https://intelliDivide.homag.cloud/optimizations/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "validationResults": []
}

Typical values and limits

Field Required Limits Note
name yes 3–100 characters Displayed in intelliDivide, for example an order or quote number
machine yes 3–100 characters Name from step 1
parameters yes 3–100 characters Name of the parameter set from step 1
action yes ImportOnly (default), Optimize, Send See below
parts[].description yes 1–100 characters Part description
parts[].materialCode yes 1–50 characters Must exist in materialManager
parts[].length, width – 0.1–9999.9 mm Finished dimensions
parts[].quantity yes 0–10000 Default 1
parts[].quantityPlus – 0–10000 Additional quantity if there is space on the board
parts[].grain yes None (default), among others Grain direction
parts[].edgeFront … edgeRight – 1–50 characters Edgeband codes

All fields and enums: OptimizationRequest and Data model.

Shortcut using action: With Optimize, intelliDivide starts optimization immediately after creation. With Send, the solution is also sent to the machine. To choose a solution yourself in step 4, keep the default ImportOnly and start the optimization yourself.

Check validation

Check the entries in validationResults (OptimizationValidationResult) before proceeding. A non-empty array means the request needs to be corrected.

if (response.ValidationResults != null && response.ValidationResults.Any())
{
    throw new ValidationException(response.ValidationResults[0].ErrorMessage);
}
# Validation results are part of the "Create an optimization" response.

{
  "optimizationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "optimizationStatus": "New",
  "validationResults": [
    {
      "memberNames": ["Parts[0].MaterialCode"],
      "errorMessage": "The material code 'UNKNOWN' is not available."
    }
  ]
}

# An empty "validationResults" array means the request is valid.

3. Monitor progress

The optimization runs asynchronously. Start it and query the status until it reaches Optimized after Started, or until it reaches a cancellation or error state. Account for all state transitions and set a time limit for unusually long runs.

// Start the optimization
await intelliDivide.StartOptimization(response.OptimizationId);

// Wait for the optimization to complete (polls the status periodically)
var optimization = await intelliDivide.WaitForCompletion(
    response.OptimizationId, TimeSpan.FromMinutes(5));
# Start the optimization
POST /api/intelliDivide/optimizations/a1b2c3d4-e5f6-7890-abcd-ef1234567890/optimize

200 OK

# Query the status until it reaches "Optimized" (or "Faulted" / "Canceled")
GET /api/intelliDivide/optimizations/a1b2c3d4-e5f6-7890-abcd-ef1234567890/state

200 OK
Content-Type: application/json

"Optimized"
Status Meaning Integration response
New Created, not started yet Start it
Queued, Started Queued or being optimized Continue polling, for example every 5–10 seconds
Optimized Solutions are available Continue with step 4
Faulted Optimization failed Check in intelliDivide and correct the request
Canceled Canceled Stop polling
Transferring, Transferred Solution is being or has been transferred to the machine Completed
Archived Archived Read only

Rules and pitfalls

  • Do not hard-code names. Always determine machines and parameter sets in step 1 and keep them configurable.
  • Validate material codes in advance. Unknown codes are only reported in validationResults. Maintain material types in materialManager (Board management).
  • Limit polling frequency. Polling too often can result in 429 (Error handling, limits, paging).
  • Reserve material. To make the requirement known to the ERP system, see Material requirements and reservation.

Endpoints

Step Method Endpoint SDK
1 GET /api/intelliDivide/machines GetMachines(), GetMachine(name)
1 GET /api/intelliDivide/{optimizationType}/parameters GetParameters(type)
1 GET /api/intelliDivide/materials/boards · /edgebands GetBoardTypes(), GetEdgebandTypes()
2 POST /api/intelliDivide/optimizations RequestOptimization(request)
2 POST /api/intelliDivide/optimizations/RequestUsingTemplate RequestOptimization(templateRequest, files)
3 POST /api/intelliDivide/optimizations/{optimizationId}/optimize StartOptimization(id)
3 GET /api/intelliDivide/optimizations/{optimizationId}/state GetOptimizationStatus(id), WaitForCompletion(id, max)

Complete signatures: Endpoints.