Изменения документа Макрос для формирования карты высот
Редактировал(а) Edgar Allan Poe 2024/11/14 17:01
От версии 3.10
отредактировано abolgov
на 2022/06/17 13:56
на 2022/06/17 13:56
Изменить комментарий:
Update document after refactoring.
Сводка
-
Свойства страницы (2 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Автор документа
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.a bolgov1 +XWiki.Knetyaga - Содержимое
-
... ... @@ -2,84 +2,82 @@ 2 2 3 3 {{code}} 4 4 function m155() 5 - local XWidth = 706 - local YWidth = 507 - local SafeZ = 38 - local ProbeZ = -39 - local StepX = 1510 - local StepY = 1511 - local Feed = 5012 - local TipHeight = 013 - local ProbeFilename = "C:\temp\probe.txt"14 - 15 - PushCurrentDistanceMode()16 - PushCurrentMotionMode()17 - 18 - if (IsProbingPinConfigured()) then19 - -- open the file20 - file, msg = io.open(ProbeFilename, "w")21 - 22 - if (file == nil) then23 - DisplayMessage("Could not open probe output file ("..msg..")")24 - Stop()25 - return26 - end27 - 28 - ExecuteMDI("F "..Feed)29 - ExecuteMDI("G90 G38.2 Z-100")30 - 31 - -- set the current location to 0,0,032 - ExecuteMDI("G92 X0Y0Z0")33 - ExecuteMDI("G0 Z"..SafeZ)34 - 35 - local direction = 036 - for y = 0, YWidth, StepY do37 - if (direction == 1) then38 - direction = 039 - else40 - direction = 141 - end42 - 43 - for x = 0, XWidth, StepX do44 - if (direction == 1) then45 - ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ)46 - else47 - ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ)48 - end49 - 50 - ExecuteMDI("G38.2 Z"..ProbeZ)51 - LogCurrentPos(TipHeight)52 - ExecuteMDI("G0 Z"..SafeZ)53 - end54 - end55 - 56 - if (direction == 1) then57 - ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ)58 - else59 - ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ)60 - end61 - 62 - local HighZ = 563 - ExecuteMDI("G0 Z"..HighZ)64 - ExecuteMDI("G0 X0Y0")65 - 66 - file:close()67 - else68 - DisplayMessage("Probe input is not configured")69 - return70 - end5 + 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 + 15 + PushCurrentDistanceMode() 16 + PushCurrentMotionMode() 17 + 18 + if (IsProbingPinConfigured()) then 19 + -- open the file 20 + file, msg = io.open(ProbeFilename, "w") 21 + 22 + if (file == nil) then 23 + DisplayMessage("Could not open probe output file ("..msg..")") 24 + Stop() 25 + return 26 + end 27 + 28 + ExecuteMDI("F "..Feed) 29 + ExecuteMDI("G90 G38.2 Z-100") 30 + 31 + -- set the current location to 0,0,0 32 + ExecuteMDI("G92 X0Y0Z0") 33 + ExecuteMDI("G0 Z"..SafeZ) 34 + 35 + local direction = 0 36 + for y = 0, YWidth, StepY do 37 + if (direction == 1) then 38 + direction = 0 39 + else 40 + direction = 1 41 + end 42 + 43 + for x = 0, XWidth, StepX do 44 + if (direction == 1) then 45 + ExecuteMDI("G0 X"..x.." Y"..y.." Z"..SafeZ) 46 + else 47 + ExecuteMDI("G0 X"..(XWidth - x).." Y"..y.." Z"..SafeZ) 48 + end 49 + 50 + ExecuteMDI("G38.2 Z"..ProbeZ) 51 + LogCurrentPos(TipHeight) 52 + ExecuteMDI("G0 Z"..SafeZ) 53 + end 54 + end 55 + 56 + if (direction == 1) then 57 + ExecuteMDI("G0 X"..XWidth.." Y"..YWidth.." Z"..SafeZ) 58 + else 59 + ExecuteMDI("G0 X".."0".." Y"..YWidth.." Z"..SafeZ) 60 + end 61 + 62 + local HighZ = 5 63 + ExecuteMDI("G0 Z"..HighZ) 64 + ExecuteMDI("G0 X0Y0") 65 + 66 + file:close() 67 + else 68 + DisplayMessage("Probe input is not configured") 69 + return 70 + end 71 71 end 72 72 73 73 function LogCurrentPos(tipHeight) 74 - local CurrX = AxisGetPos(Axis.X)75 - local CurrY = AxisGetPos(Axis.Y)76 - local CurrZ = AxisGetPos(Axis.Z)77 - 78 - local fmt = "%.5f"79 - file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n")74 + local CurrX = AxisGetPos(Axis.X) 75 + local CurrY = AxisGetPos(Axis.Y) 76 + local CurrZ = AxisGetPos(Axis.Z) 77 + 78 + local fmt = "%.5f" 79 + file:write(string.format(fmt, CurrX)..","..string.format(fmt, CurrY)..","..string.format(fmt, CurrZ - tipHeight), "\n") 80 80 end 81 81 {{/code}} 82 82 83 - 84 - 85 -{{view-file att--filename="M155.pm" name="" height="250"/}} 83 +[[Скачать макрос>>attach:M155.pm]]