Skip to content

配方

获取配方

GetRecipe

lua
recipe = GetRecipe(index)

获取一组配方

提示

需提前在配方管理页中新建或导入配方并设为默认

参数

参数类型描述
indexInteger 整数配方索引

返回值

返回值类型描述
recipeTable 表配方,失败返回nil

切换配方

GetRecipe

lua
SwitchRecipe(recipe)

切换到指定的配方

参数

参数类型描述
recipeString 字符串配方名

使用配方

假设有如下的配方文件:

json
{
  "recipe": [
    {
      "pin": 1,
      "PinHeight": 7.95,
      "PinHeightMax": 0.5,
      "PinHeightMin": 0.5,
      "PinHeightSupply": 0,
      "PinPositionX": 26.8,
      "PinPositionXMax": 0.5,
      "PinPositionXMin": 0.5,
      "PinPositionXSupply": 0,
      "PinPositionY": 8.8,
      "PinPositionYMax": 0.5,
      "PinPositionYMin": 0.5,
      "PinPositionYSupply": 0,
      "PinSideX": 3.5,
      "PinSideXMax": 0.3,
      "PinSideXMin": 0.3,
      "PinSideY": 0,
      "PinSideYMax": 0.3,
      "PinSideYMin": 0.3,
      "PinSideHight": 0,
      "PinSideHightMax": 0.3,
      "PinSideHightMin": 0.3
    },
    {
      "pin": 2,
      "PinHeight": 7.95,
      "PinHeightMax": 0.5,
      "PinHeightMin": 0.5,
      "PinHeightSupply": 0,
      "PinPositionX": 23.4,
      "PinPositionXMax": 0.5,
      "PinPositionXMin": 0.5,
      "PinPositionXSupply": 0,
      "PinPositionY": 8.8,
      "PinPositionYMax": 0.5,
      "PinPositionYMin": 0.5,
      "PinPositionYSupply": 0,
      "PinSideX": 3.5,
      "PinSideXMax": 0.3,
      "PinSideXMin": 0.3,
      "PinSideY": 0,
      "PinSideYMax": 0.3,
      "PinSideYMin": 0.3,
      "PinSideHight": 0,
      "PinSideHightMax": 0.3,
      "PinSideHightMin": 0.3
    },
  ]
}

使用配方管理器加载配方,获取第一组参数中的PinHeight参数的方法如下:

lua
recipe = GetRecipe(0)
PinHeight0 = recipe.PinHeight
println(PinHeight0)

输出

7.95

AI-Vision,让3D测量更简单