pageId = 0 screenId = 0 testcount = 0 machState = 0 machStateOld = -1 machEnabled = 0 machWasEnabled = 0 enableBlink = 0 enableBlinkCount = 0 function IsAxisEnabled(axis) local inst = mc.mcGetInstance(); local ena = mc.mcAxisIsEnabled(inst, axis); -- mc.mcCntlSetLastError(0, 'in IsAxisEnable() ena = ' .. tostring(ena)); return tostring(ena); end function AxisEnable() local inst = mc.mcGetInstance(); local ena ena = IsAxisEnabled(0); scr.SetProperty('xPos', 'Enabled', ena); scr.SetProperty('xNeg', 'Enabled', ena); scr.SetProperty('btnZeroX', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroX2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefX', 'Enabled', tostring(ena)); ena = IsAxisEnabled(1); scr.SetProperty('yPos', 'Enabled', tostring(ena)); scr.SetProperty('yNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroY', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroY2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefY', 'Enabled', tostring(ena)); ena = IsAxisEnabled(2); scr.SetProperty('zPos', 'Enabled', tostring(ena)); scr.SetProperty('zNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroZ', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroZ2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefZ', 'Enabled', tostring(ena)); ena = IsAxisEnabled(3); scr.SetProperty('aPos', 'Enabled', tostring(ena)); scr.SetProperty('aNeg', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroA', 'Enabled', tostring(ena)); scr.SetProperty('btnZeroA2', 'Enabled', tostring(ena)); scr.SetProperty('btnRefA', 'Enabled', tostring(ena)); end function getHypot(axis1, axis2) local hypot = math.sqrt(math.pow(axis1,2) + math.pow(axis2,2)); Hyp = hypot; return Hyp; end function getAngle(axis1, axis2) PI = math.pi; local radians = math.atan(axis1/axis2); local BaseAngle = radians * (180/PI) if (axis1 == 0 and axis2 == 0) then angle = 0; end if (axis2 < 0 and axis1 > 0) then BaseAngle = -(90 + BaseAngle); end if (BaseAngle < 0) then angle = (BaseAngle + 360); elseif (BaseAngle > 0) then angle = BaseAngle; end if (angle == 0 or angle == 90 or angle == 180 or angle == 270) then if (axis1 > 0 or (axis1 == 0 and axis2 == 0)) then angle = 0; elseif (axis1 < 0 and axis2 == 0) then angle = 180; elseif (axis1 == 0 and axis2 > 0) then angle = 90; elseif (axis1 == 0 and axis2 < 0) then angle = 270; end end return angle end local function isnan(val) --if val==1/0 then return "0" --elseif val==-1/0 then return "0" --elseif val~=val then return "0" --elseif val==1/1 then return "0" --elseif val== nil then return "0" return tostring(val) == '-1.#IND'; --val ~= val --end end scr.SetProperty('btnEnable', 'Label', 'Enable'); AxisEnable(); function Mach_PLC_Script() local inst = mc.mcGetInstance(); local rc = 0; testcount = testcount + 1 machState, rc = mc.mcCntlGetState(inst); local inCycle = mc.mcCntlIsInCycle(inst); --mc.mcCntlSetLastError(inst, 'machWasEnabled = ' .. tostring (machWasEnabled) .. 'machEnabled = ' .. tostring(machEnabled)); if ((machWasEnabled == 0) and (machEnabled == 1)) then --mc.mcCntlSetLastError(inst, 'Enable!'); scr.SetProperty('btnEnable', 'Label', 'Disable'); scr.SetProperty('btnEnable', 'Bg Color', '#FF0000'); --Enable controls! elseif ((machWasEnabled == 1) and (machEnabled == 0)) then --mc.mcCntlSetLastError(inst, 'Disable!'); scr.SetProperty('btnEnable', 'Label', 'Enable'); scr.SetProperty('btnEnable', 'Bg Color', ''); --Diaable controls! scr.SetProperty('CycleStart', 'Enabled', '0'); enableBlink = 0; enableBlinkCount = 0; end --Blink the enable button. if (machEnabled == 0) then enableBlinkCount = enableBlinkCount + 1; --mc.mcCntlSetLastError(inst, 'enableBlinkCount = ' .. tostring(enableBlinkCount)); if (enableBlinkCount == 10) then enableBlink = not enableBlink; --mc.mcCntlSetLastError(inst, 'enableBlink = ' .. tostring(enableBlink)); if (enableBlink == true) then scr.SetProperty('btnEnable', 'Bg Color', '#00FF00'); elseif(enableBlink == false) then scr.SetProperty('btnEnable', 'Bg Color', ''); end enableBlinkCount = 0; end end if ((machState ~= machStateOld) or (machEnable ~= machWasEnabled)) then local enaCycleStart = ((machState == mc.MC_STATE_IDLE) or (machState == mc.MC_STATE_HOLD) or (machState == mc.MC_STATE_FRUN_PROBE_FH) or (machState == mc.MC_STATE_FRUN_THREAD_FH) or (machState == mc.MC_STATE_FRUN_MACROH) or (machState == mc.MC_STATE_MRUN_FH) or (machState == mc.MC_STATE_FRUN_FH) or (machState == mc.MC_STATE_MRUN_PROBE_FH) or (machState == mc.MC_STATE_MRUN_THREAD_FH) or (machState == mc.MC_STATE_MRUN_MACROH) or (machState == mc.MC_STATE_FRUN_SINGLE_BLOCK)) enaCycleStart = (enaCycleStart and (machEnabled == 1)) local enaStop = (machState ~= mc.MC_STATE_IDLE) and (machEnabled == 1) and (machState ~= mc.MC_STATE_JOG) local enaFeedHold = (machState ~= mc.MC_STATE_IDLE) and (machEnabled == 1) and (machState ~= mc.MC_STATE_JOG) local enaReset = (machEnabled == 1) and (machState == mc.MC_STATE_IDLE) local enaJog = ((machState == mc.MC_STATE_IDLE) or (machState == mc.MC_STATE_HOLD) or (machState == mc.MC_STATE_FRUN_PROBE_FH) or (machState == mc.MC_STATE_JOG) or (machState == mc.MC_STATE_FRUN_THREAD_FH) or (machState == mc.MC_STATE_FRUN_MACROH) or (machState == mc.MC_STATE_FRUN_MACROH_JOG) or (machState == mc.MC_STATE_MRUN_FH) or (machState == mc.MC_STATE_FRUN_FH) or (machState == mc.MC_STATE_MRUN_PROBE_FH) or (machState == mc.MC_STATE_MRUN_THREAD_FH) or (machState == mc.MC_STATE_FRUN_FH_JOG) or (machState == mc.MC_STATE_MRUN_MACROH) or (machState == mc.MC_STATE_MRUN_MACROH_JOG)) enaJog = (enaJog and (machEnabled == 1)) if (enaCycleStart) then scr.SetProperty('btnCycleStart', 'Enabled', '1'); else scr.SetProperty('btnCycleStart', 'Enabled', '0'); end if (enaStop) then scr.SetProperty('btnStop', 'Enabled', '1'); else scr.SetProperty('btnStop', 'Enabled', '0'); end if (enaFeedHold) then scr.SetProperty('btnFeedHold', 'Enabled', '1'); else scr.SetProperty('btnFeedHold', 'Enabled', '0'); end if (enaReset) then scr.SetProperty('btnReset', 'Enabled', '1'); else scr.SetProperty('btnReset', 'Enabled', '0'); end -- if (enaJog) then -- scr.SetProperty('pnlJog', 'Enabled', '1'); -- JogEnable(); -- else -- scr.SetProperty('pnlJog', 'Enabled', '0'); -- end end if (machEnabled ~= machWasEnabled) then scr.SetProperty('btnRefAll', 'Enabled', tostring(machEnabled)); scr.SetProperty('btnRefAll2', 'Enabled', tostring(machEnabled)); scr.SetProperty('btnGotoZero', 'Enabled', tostring(machEnabled)); scr.SetProperty('tabJogging', 'Enabled', tostring(machEnabled)); if (machEnabled == 1) then AxisEnable(); end end SigLib = { --Enable [mc.OSIG_MACHINE_ENABLED] = function (state) machEnabled = state; end, --HeadUp [mc.ISIG_INPUT1] = function (on_off)--mc.ISIG_INPUT1 if( on_off==1 ) then -- On else -- Off end end, --HeadDn [mc.ISIG_INPUT2] = function (state)--mc.ISIG_INPUT2 if( state == 1 ) then -- On else -- Off Call A function here if you wanted end end, [mc.ISIG_INPUT3] = function (state)--mc.ISIG_INPUT3 --Used as an enable button if( state == 1 ) then local inst= mc.mcGetInstance(); local reg = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED) state = mc.mcSignalGetState(reg); if(state == 1)then state = 0 else state = 1 end mc.mcCntlEnable(inst, state); end end, [mc.ISIG_INPUT4] = function (state)--mc.ISIG_INPUT2 button to do feed hold if( state == 1 ) then local inst= mc.mcGetInstance(); mc.mcCntlFeedHold(inst) end end, [mc.ISIG_INPUT5] = function (state)--mc.ISIG_INPUT2 if( state == 1 ) then CycleStart() --Run my cycle start function end end } --local CurrentLine = scr.GetProperty('droCurrent', 'Value', mc.mcCntlGetGcodeLineNbr); local TotalLines = mc.mcCntlGetGcodeLineCount(inst); local GcodeCurrentLine = mc.mcCntlGetGcodeLineNbr(inst); local GcodePercent = (GcodeCurrentLine/TotalLines) * 100; --scr.SetProperty('droCurrent', 'Value', tostring(CurrentLine)); scr.SetProperty('droTotal', 'Value', tostring(TotalLines+1)); scr.SetProperty('droPercent', 'Value', tostring(GcodePercent)); local Xval = mc.mcAxisGetPos(inst,0); local Yval = mc.mcAxisGetPos(inst,1); local Zval = mc.mcAxisGetPos(inst,2); getAngle(Xval,Yval); scr.SetProperty('droXY', 'Value', tostring(angle)); getAngle(Xval,Zval); scr.SetProperty('droXZ', 'Value', tostring(angle)); getAngle(Yval,Zval); scr.SetProperty('droYZ', 'Value', tostring(angle)); getHypot(Xval,Yval); scr.SetProperty('droXYhyp', 'Value', tostring(Hyp)); getHypot(Xval,Zval); scr.SetProperty('droXZhyp', 'Value', tostring(Hyp)); getHypot(Yval,Zval); scr.SetProperty('droYZhyp', 'Value', tostring(Hyp)); --This is the last thing we do. So keep it at the end of the script! machStateOld = machState; machWasEnabled = machEnabled; end function Mach_Signal_Script(sig, state) local inst = mc.mcGetInstance(); if (sig == mc.OSIG_MACHINE_ENABLED) then machEnabled = state; end --if (SigLib[sig] ~= nil) then -- SigLib[sig](state); --end end function btnCycleStart_Left_Up_Script() ----Test comment --Look to see if the MDI window is being used --If the MDI window is shown execute MDI. If not run the Gcode File local inst = mc.mcGetInstance(); local rc; local tab, rc = scr.GetProperty("MainTabs", "Current Tab") --wx.wxMessageBox("tab == " .. tostring(tab) ) local test = mc.mcProfileGetInt(0, "MachMotion/Screens", "Mill", 1) if (tonumber(tab) == 1) then local state = mc.mcCntlGetState(inst); if (state == mc.MC_STATE_MRUN_MACROH) then mc.mcCntlCycleStart(inst); else scr.ExecMdi('mdi1'); end --Run MDI mc.mcCntlSetLastError(inst, "Do MDI") --wx.wxMessageBox("Do MDI")\ elseif (tonumber(tab) == 3) then local state = mc.mcCntlGetState(inst); scr.ExecMdi('mdi3'); --Run MDI mc.mcCntlSetLastError(inst, "Do MDI") --wx.wxMessageBox("Do MDI")\ else --Do CycleStart mc.mcCntlSetLastError(inst, "Do Cycle Start") mc.mcCntlCycleStart(inst) --wx.wxMessageBox("Do Cycle Start") end end function btnReset_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcCntlReset(inst); end function btnCfgTPViews_Left_Up_Script() local inst = mc.mcGetInstance(); local rc; local tab, rc = scr.GetProperty("MainTabs", "Current Tab") --wx.wxMessageBox("tab == " .. tostring(tab) ) local test = mc.mcProfileGetInt(0, "MachMotion/Screens", "Mill", 1) local Message = "";--for debugging with wxMessageBox local TPGrpPanels ={}; if (tonumber(tab) == 0) then function GetToolPathPanelProperties(TPgrpPanalPropertyName, IndexOfTPgrpPanelPropertyName) local TPGrpPanalProp = {}; local rc, name, top, left, height, width, enabled, hidden, z_order, label; if TPgrpPanalPropertyName == nil then wx.wxMessageBox("TPpanel name can't be blank!"); end if (IndexOfTPgrpPanelPropertyName == nil) or (IndexOfTPgrpPanelPropertyName <= 0) then wx.wxMessageBox("TPpanel Index must be + Int!"); end name, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Name'); if rc == 0 then TPGrpPanalProp.name = name; else wx.wxMessageBox("GetProperty Error on: 'PnlName'"); end top, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Top'); if rc == 0 then TPGrpPanalProp.top = top; else wx.wxMessageBox("GetProperty Error on: 'PnlTop'"); end left, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Left'); if rc == 0 then TPGrpPanalProp.left = left; else wx.wxMessageBox("GetProperty Error on: 'PnlLeft'"); end height, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Height'); if rc == 0 then TPGrpPanalProp.height = height; else wx.wxMessageBox("GetProperty Error on: 'PnlHeight'"); end width, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Width'); if rc == 0 then TPGrpPanalProp.width = width; else wx.wxMessageBox("GetProperty Error on: 'PnlWidth'"); end enabled, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Enabled'); if rc == 0 then TPGrpPanalProp.enabled = enabled; else wx.wxMessageBox("GetProperty Error on: 'PnlEnabled'"); end hidden, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Hidden'); if rc == 0 then TPGrpPanalProp.hidden = hidden; else wx.wxMessageBox("GetProperty Error on: 'PnlHidden'"); end z_Order, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Z Order'); if rc == 0 then TPGrpPanalProp.z_order = z_Order; else wx.wxMessageBox("GetProperty Error on: 'PnlZ Order'"); end label, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Label'); if rc == 0 then TPGrpPanalProp.label = label; else wx.wxMessageBox("GetProperty Error on: 'PnlLabel'"); end TPGrpPanalProp.TPPropName = TPgrpPanalPropertyName; TbleIndx = IndexOfTPgrpPanelPropertyName; TPGrpPanels[TbleIndx] = TPGrpPanalProp; end --Tool Path/group user data table, for the "Run" Page tool group and tool path area --The first element [1], is a table of toolpath property names, 4 of them local RunPgTPUserData = {{'toolpath11','toolpath12','toolpath13','toolpath14'}};--The 4 toolpath property names RunPgTPUserData.panelname = 'grpToolPath'; --[2]Property name for the panel of the tool paths RunPgTPUserData.NumOfToolPaths = 4; --[3]Number of tool paths in the parent panel RunPgTPUserData.LeftMargin = 10; --[4]10 pixel Left margin for tool paths is from the parant panel edge RunPgTPUserData.RightMargin = 10; --[5]10 pixel Right margin for tool paths is from the parant panel edge RunPgTPUserData.TopMargin = 16; --[6]16 pixel Top margin for tool paths is from the parant panel edge RunPgTPUserData.BottomMargin = 10; --[7]10 pixel Bottom margin for tool paths is from the parant panel edge --On Accept Btn from wx layout view choice dialog function ArrangeToolPathAnchors(LayoutType) --Layout type, is string of toolpath view layout local WidthDisplayArea = 0; local HeightDisplayArea = 0; local rc = 0; GetToolPathPanelProperties(RunPgTPUserData.panelname, 1); WidthDisplayArea = TPGrpPanels[1].width - (RunPgTPUserData.LeftMargin + RunPgTPUserData.RightMargin); HeightDisplayArea = TPGrpPanels[1].height - (RunPgTPUserData.TopMargin + RunPgTPUserData.BottomMargin); testvar = 0; if (WidthDisplayArea%2 ~= 0) then--if size not even # then subtract 1 pixel for total width WidthDisplayArea = (WidthDisplayArea - 1); testvar = 0; end if (HeightDisplayArea%2 ~= 0) then--if size not even # then subtract 1 pixel for total height HeightDisplayArea = (HeightDisplayArea - 1); testvar = 0; end --Set all toolpath objects to Z Order level 1 for x = 1, RunPgTPUserData.NumOfToolPaths, 1 do rc = scr.SetProperty(RunPgTPUserData[1][x], 'Z Order', '1');--set all 4 tp to "Z" level 0 rc = scr.SetProperty(RunPgTPUserData[1][x], 'Hidden', '1');--Hide all 4 tp testvar = 0; end local Z_OrderViewVar = '2'; --SINGLE VIEW TOOL PATH toolpath11 is on top, covers entire display space if LayoutType == "SingleView" then rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 testvar = 0; end --HORIZONTAL VIEW TOOL PATHS toolpath11 on top half, toolpath13 on bottom half if LayoutType == "SplitHorizontal" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin +(HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 end --VERTICAL VIEW TOOL PATHS toolpath11 leftside, toolpath12 right side if LayoutType == "SplitVertical" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath12 rc = scr.SetProperty(RunPgTPUserData[1][2], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][2], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][2], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][2], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][2], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath12 to on top rc = scr.SetProperty(RunPgTPUserData[1][2], 'Hidden', '0');--Show toolpath12 end --THREE VIEW TOOL PATH toolpath11 on top 1/2, toolpath 13 & 13 split on bottom 1/2 if LayoutType == "ThreeView" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 --toolpath14 rc = scr.SetProperty(RunPgTPUserData[1][4], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][4], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][4], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath14 to on top rc = scr.SetProperty(RunPgTPUserData[1][4], 'Hidden', '0');--Show toolpath14 end --FOUR VIEW TOOL PATH toolpath11-12 in top 1/2, 13-14 in bottom 1/2 if LayoutType == "FourView" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath12 rc = scr.SetProperty(RunPgTPUserData[1][2], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][2], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][2], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][2], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][2], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath12 to on top rc = scr.SetProperty(RunPgTPUserData[1][2], 'Hidden', '0');--Show toolpath12 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 --toolpath14 rc = scr.SetProperty(RunPgTPUserData[1][4], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][4], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][4], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath14 to on top rc = scr.SetProperty(RunPgTPUserData[1][4], 'Hidden', '0');--Show toolpath14 end end RunPageLastScreenLayoutView = ""; local RunPageLastScreenLayoutView = mc.mcProfileGetString(0 , "RunPageTPlayout", "ViewType", "FourView");--get last view choice local ToolPathLayoutViewTbl = {"SingleView","SplitHorizontal","SplitVertical","ThreeView","FourView"} local RPLSLV = RunPageLastScreenLayoutView; if RPLSLV ~= "SingleView" and RPLSLV ~= "SplitHorizontal" and RPLSLV ~= "SplitVertical" and RPLSLV ~= "ThreeView" and RPLSLV ~= "FourView" then RunPageLastScreenLayoutView = "FourView"; mc.mcProfileWriteString(0 ,"RunPageTPlayout", "ViewType", "FourView"); end local a = 0 while a < #ToolPathLayoutViewTbl do local TblInxVar = a + 1; if TblInxVar == 6 then TblInxVar = 1; end local TblViewNameList = ToolPathLayoutViewTbl[TblInxVar]; if RunPageLastScreenLayoutView == TblViewNameList then if TblInxVar == 5 then TblInxVar = 0; end local NewView = ToolPathLayoutViewTbl[TblInxVar + 1]; mc.mcProfileWriteString(0 ,"RunPageTPlayout", "ViewType", tostring(NewView)); ArrangeToolPathAnchors(NewView); end a = a + 1; end rc = scr.SetProperty('MainTabs', 'Current Tab', '1'); --wx.wxSleep(1); rc = scr.SetProperty('MainTabs', 'Current Tab', '0'); elseif (tonumber(tab) == 2) then function GetToolPathPanelProperties(TPgrpPanalPropertyName, IndexOfTPgrpPanelPropertyName) local TPGrpPanalProp = {}; local rc, name, top, left, height, width, enabled, hidden, z_order, label; if TPgrpPanalPropertyName == nil then wx.wxMessageBox("TPpanel name can't be blank!"); end if (IndexOfTPgrpPanelPropertyName == nil) or (IndexOfTPgrpPanelPropertyName <= 0) then wx.wxMessageBox("TPpanel Index must be + Int!"); end name, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Name'); if rc == 0 then TPGrpPanalProp.name = name; else wx.wxMessageBox("GetProperty Error on: 'PnlName'"); end top, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Top'); if rc == 0 then TPGrpPanalProp.top = top; else wx.wxMessageBox("GetProperty Error on: 'PnlTop'"); end left, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Left'); if rc == 0 then TPGrpPanalProp.left = left; else wx.wxMessageBox("GetProperty Error on: 'PnlLeft'"); end height, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Height'); if rc == 0 then TPGrpPanalProp.height = height; else wx.wxMessageBox("GetProperty Error on: 'PnlHeight'"); end width, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Width'); if rc == 0 then TPGrpPanalProp.width = width; else wx.wxMessageBox("GetProperty Error on: 'PnlWidth'"); end enabled, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Enabled'); if rc == 0 then TPGrpPanalProp.enabled = enabled; else wx.wxMessageBox("GetProperty Error on: 'PnlEnabled'"); end hidden, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Hidden'); if rc == 0 then TPGrpPanalProp.hidden = hidden; else wx.wxMessageBox("GetProperty Error on: 'PnlHidden'"); end z_Order, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Z Order'); if rc == 0 then TPGrpPanalProp.z_order = z_Order; else wx.wxMessageBox("GetProperty Error on: 'PnlZ Order'"); end label, rc = scr.GetProperty(TPgrpPanalPropertyName, 'Label'); if rc == 0 then TPGrpPanalProp.label = label; else wx.wxMessageBox("GetProperty Error on: 'PnlLabel'"); end TPGrpPanalProp.TPPropName = TPgrpPanalPropertyName; TbleIndx = IndexOfTPgrpPanelPropertyName; TPGrpPanels[TbleIndx] = TPGrpPanalProp; end --Tool Path/group user data table, for the "Run" Page tool group and tool path area --The first element [1], is a table of toolpath property names, 4 of them local RunPgTPUserData = {{'toolpath15','toolpath16','toolpath17','toolpath18'}};--The 4 toolpath property names RunPgTPUserData.panelname = 'grpToolPath2'; --[2]Property name for the panel of the tool paths RunPgTPUserData.NumOfToolPaths = 4; --[3]Number of tool paths in the parent panel RunPgTPUserData.LeftMargin = 10; --[4]10 pixel Left margin for tool paths is from the parant panel edge RunPgTPUserData.RightMargin = 10; --[5]10 pixel Right margin for tool paths is from the parant panel edge RunPgTPUserData.TopMargin = 16; --[6]16 pixel Top margin for tool paths is from the parant panel edge RunPgTPUserData.BottomMargin = 10; --[7]10 pixel Bottom margin for tool paths is from the parant panel edge --On Accept Btn from wx layout view choice dialog function ArrangeToolPathAnchors(LayoutType) --Layout type, is string of toolpath view layout local WidthDisplayArea = 0; local HeightDisplayArea = 0; local rc = 0; GetToolPathPanelProperties(RunPgTPUserData.panelname, 1); WidthDisplayArea = TPGrpPanels[1].width - (RunPgTPUserData.LeftMargin + RunPgTPUserData.RightMargin); HeightDisplayArea = TPGrpPanels[1].height - (RunPgTPUserData.TopMargin + RunPgTPUserData.BottomMargin); testvar = 0; if (WidthDisplayArea%2 ~= 0) then--if size not even # then subtract 1 pixel for total width WidthDisplayArea = (WidthDisplayArea - 1); testvar = 0; end if (HeightDisplayArea%2 ~= 0) then--if size not even # then subtract 1 pixel for total height HeightDisplayArea = (HeightDisplayArea - 1); testvar = 0; end --Set all toolpath objects to Z Order level 1 for x = 1, RunPgTPUserData.NumOfToolPaths, 1 do rc = scr.SetProperty(RunPgTPUserData[1][x], 'Z Order', '1');--set all 4 tp to "Z" level 0 rc = scr.SetProperty(RunPgTPUserData[1][x], 'Hidden', '1');--Hide all 4 tp testvar = 0; end local Z_OrderViewVar = '2'; --SINGLE VIEW TOOL PATH toolpath11 is on top, covers entire display space if LayoutType == "SingleView" then rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 testvar = 0; end --HORIZONTAL VIEW TOOL PATHS toolpath11 on top half, toolpath13 on bottom half if LayoutType == "SplitHorizontal" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin +(HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 end --VERTICAL VIEW TOOL PATHS toolpath11 leftside, toolpath12 right side if LayoutType == "SplitVertical" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath12 rc = scr.SetProperty(RunPgTPUserData[1][2], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][2], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][2], 'Height', tostring(HeightDisplayArea) );--FULLdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][2], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][2], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath12 to on top rc = scr.SetProperty(RunPgTPUserData[1][2], 'Hidden', '0');--Show toolpath12 end --THREE VIEW TOOL PATH toolpath11 on top 1/2, toolpath 13 & 13 split on bottom 1/2 if LayoutType == "ThreeView" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea) );--FULLdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 --toolpath14 rc = scr.SetProperty(RunPgTPUserData[1][4], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][4], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][4], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath14 to on top rc = scr.SetProperty(RunPgTPUserData[1][4], 'Hidden', '0');--Show toolpath14 end --FOUR VIEW TOOL PATH toolpath11-12 in top 1/2, 13-14 in bottom 1/2 if LayoutType == "FourView" then --toolpath11 rc = scr.SetProperty(RunPgTPUserData[1][1], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][1], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][1], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][1], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath11 to on top rc = scr.SetProperty(RunPgTPUserData[1][1], 'Hidden', '0');--Show toolpath11 --toolpath12 rc = scr.SetProperty(RunPgTPUserData[1][2], 'Top', tostring(RunPgTPUserData.TopMargin) );--topmargin rc = scr.SetProperty(RunPgTPUserData[1][2], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][2], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][2], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][2], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath12 to on top rc = scr.SetProperty(RunPgTPUserData[1][2], 'Hidden', '0');--Show toolpath12 --toolpath13 rc = scr.SetProperty(RunPgTPUserData[1][3], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][3], 'Left', tostring(RunPgTPUserData.LeftMargin) );--leftmargin rc = scr.SetProperty(RunPgTPUserData[1][3], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][3], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][3], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath13 to on top rc = scr.SetProperty(RunPgTPUserData[1][3], 'Hidden', '0');--Show toolpath13 --toolpath14 rc = scr.SetProperty(RunPgTPUserData[1][4], 'Top', tostring(RunPgTPUserData.TopMargin + (HeightDisplayArea/2)) );--HorzMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Left', tostring(RunPgTPUserData.LeftMargin + (WidthDisplayArea/2)) );--VertMidLine rc = scr.SetProperty(RunPgTPUserData[1][4], 'Height', tostring(HeightDisplayArea/2) );--HALFdisplay ht rc = scr.SetProperty(RunPgTPUserData[1][4], 'Width', tostring(WidthDisplayArea/2) );--HALFdisplay wh rc = scr.SetProperty(RunPgTPUserData[1][4], 'Z Order', tostring(Z_OrderViewVar) );--set toolpath14 to on top rc = scr.SetProperty(RunPgTPUserData[1][4], 'Hidden', '0');--Show toolpath14 end end RunPageLastScreenLayoutView = ""; local RunPageLastScreenLayoutView = mc.mcProfileGetString(0 , "RunPageTPlayout", "ViewType", "FourView");--get last view choice local ToolPathLayoutViewTbl = {"SingleView","SplitHorizontal","SplitVertical","ThreeView","FourView"} local RPLSLV = RunPageLastScreenLayoutView; if RPLSLV ~= "SingleView" and RPLSLV ~= "SplitHorizontal" and RPLSLV ~= "SplitVertical" and RPLSLV ~= "ThreeView" and RPLSLV ~= "FourView" then RunPageLastScreenLayoutView = "FourView"; mc.mcProfileWriteString(0 ,"RunPageTPlayout", "ViewType", "FourView"); end local a = 0 while a < #ToolPathLayoutViewTbl do local TblInxVar = a + 1; if TblInxVar == 6 then TblInxVar = 1; end local TblViewNameList = ToolPathLayoutViewTbl[TblInxVar]; if RunPageLastScreenLayoutView == TblViewNameList then if TblInxVar == 5 then TblInxVar = 0; end local NewView = ToolPathLayoutViewTbl[TblInxVar + 1]; mc.mcProfileWriteString(0 ,"RunPageTPlayout", "ViewType", tostring(NewView)); ArrangeToolPathAnchors(NewView); end a = a + 1; end rc = scr.SetProperty('MainTabs', 'Current Tab', '1'); --wx.wxSleep(1); rc = scr.SetProperty('MainTabs', 'Current Tab', '2'); end end function btnGotoZero_Left_Down_Script() local inst = mc.mcGetInstance() --mc.mcCntlMdiExecute(inst, 'G00 G91 Z.1') mc.mcCntlMdiExecute(inst, 'G00 G90 X0 Y0 Z0 A0') --mc.mcCntlMdiExecute(inst, 'G00 Z0') end function btnRefAll_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisHomeAll(inst); end function btnDeRef2_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisDerefAll(inst); end function btnRefAll2_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisHome(inst,3); wx.wxSleep(5); if (mc.mcAxisHomeComplete(inst, 3)) then mc.mcAxisHome(inst,2); end wx.wxSleep(5); if (mc.mcAxisHomeComplete(inst, 2)) then mc.mcAxisHome(inst,0); end wx.wxSleep(5); if (mc.mcAxisHomeComplete(inst, 0)) then mc.mcAxisHome(inst,1); end end function btnDerefAll_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisDerefAll(inst); end function btnDeRef_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisDerefAll(inst); end function btnDerefAll2_Left_Up_Script() local inst = mc.mcGetInstance(); mc.mcAxisDerefAll(inst); end function btnGOTO_Left_Down_Script() local inst = mc.mcGetInstance() --mc.mcCntlMdiExecute(inst, 'G00 G91 Z1') mc.mcCntlMdiExecute(inst, 'G00 G90 X0 Y0 Z1 A0') --mc.mcCntlMdiExecute(inst, 'G00 Z1') end function btnSpindleCW_Left_Up_Script() local inst = mc.mcGetInstance(); local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON); local sigState = mc.mcSignalGetState(sigh); if (sigState == 1) then mc.mcSpindleSetDirection(inst, 0); else mc.mcSpindleSetDirection(inst, 1); end end function btnSpindleCCW_Left_Up_Script() local inst = mc.mcGetInstance(); local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON); local sigState = mc.mcSignalGetState(sigh); if (sigState == 1) then mc.mcSpindleSetDirection(inst, 0); else mc.mcSpindleSetDirection(inst, -1); end end