Hello Guest it is April 17, 2024, 08:16:25 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DazTheGas

331
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 05:13:55 PM »
Change the filename to  load_modules.mcs

DazTheGas

332
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 01:00:33 PM »
You will need to make sure the path to the module  is included before the require, this is already set in the screen load script but still ok to put again

Code: [Select]
    local profile = mc.mcProfileGetName(inst)
    local path = mc.mcCntlGetMachDir(inst)
   
    package.path = path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;" .. path .. "\\Modules\\?.lua;"

when using require it will look in these path locations for the module

DazTheGas

333
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 10:23:11 AM »
Nice example ;-)

Simple way to put it is Private and Public Functions

No prefix = Private function being used internally by the module and cannot be run from outside of the script
With prefix = Public function that can be run/called externally using the prefix you gave it during requiring.

DazTheGas

334
Mach4 General Discussion / Re: Understanding Lua
« on: December 19, 2016, 05:25:38 AM »
Prb is a derived class (or module for lua) of Probing.

when requiring a module the module name is replaced by what we tell it, in this case its prb, so although you will see Prb.SingleSurfZ its actually running Probing.SingleSurfZ.

seems weird but look at it this way, lets take a module that creates a button called btnCreate and within that module there is a function btnCreate.createButton(coords etc)

we need 3 buttons so we can do this

local btn1 = require btnCreate
local btn2 = require btnCreate
local btn3 = require btnCreate



btn1.createButton(coords etc)
btn2.createButton(coords etc)
btn3.createButton(coords etc)

so btn1 -2 and 3 becomes derived classes/modules of btnCreate.

DazTheGas

335
Mach4 General Discussion / Re: Can i edit or add to a Predefined Macro?
« on: December 16, 2016, 11:09:31 AM »
Prob best to create another custom m code and then edit your post processor to use that instead of m30

Well thats what I did

DazTheGas

336
Mach4 General Discussion / Re: Feed Rate Override Absolute Value?
« on: December 16, 2016, 11:03:36 AM »
This runs a function that is within the Screen Load Script that simply runs an mdi code.

Code: [Select]
function GoToWorkZero()
    mc.mcCntlMdiExecute(inst, "G00 X0 Y0 A0")--Without Z moves
    --mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end

DazTheGas

337
Mach4 General Discussion / Re: Mach 4 Bug showing in M6 Script
« on: December 15, 2016, 09:42:45 AM »
It got me too ;-)

DazTheGas

338
Mach4 General Discussion / Re: Mach 4 Bug showing in M6 Script
« on: December 15, 2016, 08:39:18 AM »
Go into your Mach4 Config and select the Tools tab, You will find a "Tool Change Type" section, change this too "T on M6 line is tool to use", Voila it should now work ;-)

DazTheGas

339
Mach4 Videos / Re: Creating a function for the Screen Load Script
« on: December 15, 2016, 04:31:14 AM »
Glad it helped :-)

DazTheGas

340
Mach4 Videos / Re: Creating a function for the Screen Load Script
« on: December 14, 2016, 05:12:34 PM »
Ok have a little play with something like this

in the events tab for the enable button delete the Down Action and place this in the Down Script

Code: [Select]
local inst = mc.mcGetInstance()

function CheckHomeState()
    local en_axis = 0
    repeat
        local Is_Enabled = mc.mcAxisIsEnabled(inst, en_axis)
            if Is_Enabled == 1 then
                local is_Homed = mc.mcAxisIsHomed(inst, en_axis)
                if is_Homed ~= 1 then
                   HomeDialog()
                return  
                end
            end
        en_axis = en_axis + 1
    until( en_axis == 6 )
mc.mcCntlEnable(inst, 1)
end

function HomeDialog()
local h_dialog = wx.wxMessageDialog(wx.NULL,"Clicking Ok will Home all Axis, Cancel will abort", "Warning Machine Not Homed",wx.wxOK + wx.wxCANCEL)
local test = h_dialog:ShowModal()
    if test == wx.wxID_OK then
        mc.mcCntlEnable(inst, 1)
        wait = coroutine.create (RefAllHome)
    else
        scr.SetProperty('tbutton2','Button State','Up')
        return
    end
end

CheckHomeState()

Seems to work ok on my machine :-)

DazTheGas