Hello Guest it is April 24, 2024, 12:57:59 AM

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

41
Mach4 General Discussion / Re: lua panel and scripting help
« on: January 27, 2019, 03:02:58 AM »
Lua Panels are not Global and run in their own private environment so cannot see any functions that are declared within the screen load script, and equally anything that is declared in a panel cannot be seen by the GUI. But there is a simple way around this, when leaving the GUI editor a file called ScreenScript.lua is saved which is a copy of your screen load script. We simply load this into the panel giving it access to all the functions that were created there.

Code: [Select]
dofile(mc.mcCntlGetMachDir(0)..'\\ScreenScript.lua')
DazTheGas

42
Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 21, 2019, 05:26:53 PM »
Quote
But sizers rule!!!

Totally agree ;-)

43
Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 21, 2019, 02:37:03 PM »
When creating a Frame by default it will add a menu bar and the close icon as a minimum so you still see the frame, the wxFRAME_TOOL_WINDOW doesnt so works good as a dummy frame. You can declare the dialog however you like, that code is something I just threw together as an example.

Smurph is absolutely correct about wxFormBuilder, best is to just have a play and then have a look at the code it spits out to see how things are put together and as you can see from my code you dont actually have to use sizers if you dont want too, you can make dialogs, msg`s etc absolute.

DazTheGas

44
Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 21, 2019, 09:56:18 AM »
If all you want to do is get NUMERIC characters from a user then just use a validator on the TextCtrl, by using the wxFILTER_NUMERIC you will get your 0-9 and your - and . oh and an e

Here`s a dirty way of getting rid of the frame too and center the dialog ;-)

Code: [Select]
coords_val = ""
coordsObj = wxlua.wxLuaObject(coords_val)

mainFrame = wx.wxFrame( wx.NULL, wx.wxID_ANY, "Dummy Frame", wx.wxDefaultPosition, wx.wxSize(0,0), wx.wxFRAME_TOOL_WINDOW)
dialog = wx.wxDialog(mainFrame, wx.wxID_ANY, "Enter Coords")
dialog:Center()
coords = wx.wxTextCtrl(dialog, wx.wxID_ANY, "",  wx.wxPoint( 10,12 ), wx.wxDefaultSize, 0,  wx.wxTextValidator(wx.wxFILTER_NUMERIC, coordsObj))
ok = wx.wxButton( dialog, wx.wxID_OK, "OK", wx.wxPoint( 10,40 ), wx.wxDefaultSize, 0 )
cancel = wx.wxButton( dialog, wx.wxID_CANCEL, "Cancel", wx.wxPoint( 100,40 ), wx.wxDefaultSize, 0 )

if dialog:ShowModal() == wx.wxID_OK then
    wx.wxMessageBox(tostring(coords:GetValue()))
else
wx.wxMessageBox('User Canx')
end

Most of these "convenience functions" are just that ;-)

DazTheGas

45
Mach4 General Discussion / Re: mach4 script buttons help
« on: December 31, 2018, 06:49:08 PM »
Heres a couple of small snippets from one of my old screens how I did a button

Code: [Select]
local sethome_btn_dis = btn_path.."sethome_dis.png"
local sethome_btn_dwn = btn_path.."sethome_dwn.png"
local sethome_btn_up = btn_path.."sethome_up.png"
local sethome_btn_hov = btn_path.."sethome_hov.png"

Cont.sethome_btn = wx.wxBitmapButton( Cont.Panel, wx.wxID_ANY, wx.wxBitmap( sethome_btn_up, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(10,440), wx.wxDefaultSize, wx.wxBU_AUTODRAW + wx.wxNO_BORDER)
Cont.sethome_btn:SetBackgroundColour( wx.wxSystemSettings.GetColour( wx.wxSYS_COLOUR_ACTIVECAPTION ) )

Cont.sethome_btn:SetBitmapDisabled( wx.wxBitmap( sethome_btn_dis, wx.wxBITMAP_TYPE_ANY ) )
Cont.sethome_btn:SetBitmapSelected( wx.wxBitmap( sethome_btn_dwn, wx.wxBITMAP_TYPE_ANY ) )
Cont.sethome_btn:SetBitmapFocus( wx.wxBitmap( sethome_btn_up, wx.wxBITMAP_TYPE_ANY ) )
Cont.sethome_btn:SetBitmapHover( wx.wxBitmap( sethome_btn_hov, wx.wxBITMAP_TYPE_ANY ) )
--Cont.sethome_btn:SetToolTip( "Cycle Start" )


Cont.sethome_btn:Connect( wx.wxEVT_LEFT_UP, function(event)


    event:Skip()
    end )

Now another way of doing it is to use one of your images as a container for a second image then use the :Show() and :Hide() functions - notice in the example below that the button_up is loaded over the button_dwn, by hiding button_up then you see button_dwn and by showing it you hide button down..


Code: [Select]
--************************** Start Controls *********************************
DTG.panel = mcLuaPanelParent
 
    DTG.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )

    DTG.button_dwn = wx.wxStaticBitmap( DTG.panel, wx.wxID_ANY, wx.wxBitmap( btn_dwn, wx.wxBITMAP_TYPE_ANY ), wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
DTG.button_up = wx.wxStaticBitmap( DTG.button_dwn, wx.wxID_ANY, wx.wxBitmap( btn_up, wx.wxBITMAP_TYPE_ANY ), wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
DTG.bSizer1:Add( DTG.button_dwn, 0, wx.wxALL, 0 )

DTG.panel:SetSizer( DTG.bSizer1 )
DTG.panel:Layout()
   
--***************************  End Controls  **************************************

--************************** Start Event Handlers *********************************

    DTG.button_up:Connect( wx.wxEVT_LEFT_DOWN, function(event)
DTG.button_up:Hide();
end )

DTG.button_dwn:Connect( wx.wxEVT_LEFT_UP, function(event)
DTG.button_up:Show();
    end )

DTG.button_dwn:Connect( wx.wxEVT_LEAVE_WINDOW, function(event)
DTG.button_up:Show();
end )


--***************************  End Event Handlers  *********************************

DazTheGas

46
Mach4 General Discussion / Re: mach4 script buttons help
« on: December 31, 2018, 11:49:22 AM »
You will need to use the screen (scr) api, first load an image via the image editor then you can call it from a script.

Lets say you have a bitmap button called enable that has an image assigned to it and when pressed you want it to change then you would use scr.SetProperty('ButtonName','Image','NewImageName')

DazTheGas

47
Mach4 Videos / Constant Surface Speed using Lua
« on: December 28, 2018, 06:42:36 AM »
Well been doing a lot of mill turning on the mill lately so needed a way to do constant surface speed instead of manually raising the spindle speed using the spindle override, so I sat and during a coffee came up with this short and simple script for mach4.

All the instruction on use are in the video and the script is attached to save ya typing.

Enjoy
DazTheGas

Video with install instructions


48
Mach4 Videos / Using the ESS Probing Registers with Mach4
« on: December 27, 2018, 12:12:24 PM »
Hope this gives you some idea of how to use the new probing registers for the ESS

https://youtu.be/AthCnSaqV08

DazTheGas

49
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: December 24, 2018, 06:40:10 PM »
Hey Daz, thank you for your work ! Just a quick question, does the controller script work for slaved axes aswell ?

Yes it does, you are moving an axis not individual motors so if you have a Y axis that consists of say motors 1 and 4 then both of these will move if you command the Y axis to move.

DazTheGas

50
Mach4 Videos / Repair a Mach4 Screenset
« on: November 27, 2018, 05:44:27 PM »
What to do if your screenset becomes unloadable.

https://youtu.be/T8-vhl1tWBg

DazTheGas