Изменения документа Макрос для формирования карты высот
Редактировал(а) Edgar Allan Poe 2024/11/14 17:01
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -2,26 +2,30 @@ 2 2 3 3 {{code language="lua"}} 4 4 function m155() 5 - local XWidth = 70 6 - local YWidth = 50 7 - local SafeZ = 3 8 - local ProbeZ = -3 9 - local StepX = 15 10 - local StepY = 15 11 - local Feed = 50 12 - local TipHeight = 0 13 - local ProbeFilename = "C:\temp\probe.txt" 5 + local XWidth = 70 6 + local YWidth = 50 7 + local SafeZ = 3 8 + local ProbeZ = -3 9 + local StepX = 15 10 + local StepY = 15 11 + local Feed = 50 12 + local TipHeight = 0 13 + local ProbeFilename = "C:\temp\probe.txt" 14 14 15 - PushCurrentDistanceMode() 16 - PushCurrentMotionMode() 17 - 18 - if (IsProbingPinConfigured()) then 19 - file, msg = io.open(ProbeFilename, "w") -- open the file 15 + PushCurrentDistanceMode() 16 + PushCurrentMotionMode() 17 + 18 + if (IsProbingPinConfigured()) then 19 + file, msg = io.open(ProbeFilename, "w") -- open the file 20 + else 21 + DisplayMessage("Probe input is not configured") 22 + return 23 + end 20 20 21 21 if (file == nil) then 22 - DisplayMessage("Could not open probe output file ("..msg..")") 23 - Stop() 24 - return 26 + DisplayMessage("Could not open probe output file ("..msg..")") 27 + Stop() 28 + return 25 25 end 26 26 27 27 ExecuteMDI("F "..Feed) ... ... @@ -32,29 +32,30 @@ 32 32 33 33 local direction = 0 34 34 for y = 0, YWidth, StepY do 35 - if (direction == 1) then 36 - direction = 0 37 - else 38 - direction = 1 39 - end 40 - 41 - for x = 0, XWidth, StepX do 42 42 if (direction == 1) then 43 - ExecuteMDI("G0X"..x.."Y"..y.." Z"..SafeZ)40 + direction = 0 44 44 else 45 - ExecuteMDI("G0 X"..(XWidth-x).." Y"..y.." Z"..SafeZ)42 + direction = 1 46 46 end 44 + 45 + for x = 0, XWidth, StepX do 46 + if (direction == 1) then 47 + ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ) 48 + else 49 + ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ) 50 + end 47 47 48 - ExecuteMDI("G38.2 Z"..ProbeZ) 49 - LogCurrentPos(TipHeight) 50 - ExecuteMDI("G0 Z"..SafeZ) 51 - end 52 + ExecuteMDI("G38.2 Z"..ProbeZ) 53 + LogCurrentPos(TipHeight) 54 + ExecuteMDI("G0 Z"..SafeZ) 55 + end 56 + 52 52 end 53 53 54 54 if (direction == 1) then 55 - ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ) 60 + ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ) 56 56 else 57 - ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ) 62 + ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ) 58 58 end 59 59 60 60 local HighZ = 5 ... ... @@ -62,19 +62,16 @@ 62 62 ExecuteMDI("G0 X0Y0") 63 63 64 64 file:close() 65 - else 66 - DisplayMessage("Probe input is not configured") 67 - return 68 - end 69 69 end 70 70 71 71 function LogCurrentPos(tipHeight) 72 - local CurrX = AxisGetPos(Axis.X) 73 - local CurrY = AxisGetPos(Axis.Y) 74 - local CurrZ = AxisGetPos(Axis.Z) 73 + local CurrX = AxisGetPos(Axis.X) 74 + local CurrY = AxisGetPos(Axis.Y) 75 + local CurrZ = AxisGetPos(Axis.Z) 75 75 76 - local fmt = "%.5f" 77 - file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n") 77 + local fmt = "%.5f" 78 + file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..",".. 79 + string.format(fmt, CurrZ - tipHeight), "\n") 78 78 end 79 79 {{/code}} 80 80