Hello Guest it is May 14, 2024, 09:14:16 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 - Bill_O

271
Mach4 General Discussion / Re: set selected tool
« on: August 18, 2020, 08:36:31 AM »
Swifty,

I want to set the Selected Tool not the Current Tool.

Bill

272
Mach4 General Discussion / set selected tool
« on: August 17, 2020, 04:12:59 PM »
I have a button to raise and lower the selected tool number.
The code works one time then I must exit Mach for it to work again.
I can not find any way to set the selected tool number other than using the gcode.

Code: [Select]
local inst = mc.mcGetInstance()
local Tool = mc.mcToolGetSelected(inst)
--get max tools
local ATCMaxTlsReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCMaxTools')
local ATCMaxTlsVal = mc.mcRegGetValue(ATCMaxTlsReg)

--if tool is in range add one to tool #
if (Tool <= (ATCMaxTlsVal - 1)) then
Tool = (Tool + 1)
mc.mcCntlGcodeExecute(inst, string.format("T" .. Tool))
end


Thanks,
Bill

273
Mach4 General Discussion / Re: Mach4 laser on CNC router setup questions
« on: August 14, 2020, 12:02:53 PM »
Raptor,

Thank you for the information

Bill

274
Mach4 General Discussion / Re: Mach4 laser on CNC router setup questions
« on: August 13, 2020, 05:22:05 PM »
Did you ever get the macros done?
I would like to see the code for the head shift if you do not mind.

275
Mach4 General Discussion / Re: message box with yes or no
« on: August 11, 2020, 12:20:13 PM »
Swifty,

Worked great.
I had tried some code similar to what you showed but was missing a few little things.
Thanks for the help.

Bill

276
Mach4 General Discussion / message box with yes or no
« on: August 11, 2020, 10:57:50 AM »
I found some old threads about different message boxes.
I could use one with a yes or no option.
When I did any option for the message box it gave me an error.
Why is this code not working?

Code: [Select]
--------------------------------------
--test
---------------------------------------
function Test()
inst = mc.mcGetInstance()
rc = wx.wxMessageBox("Testing yes no box",2)
if (rc == 2) then
wx.wxMessageBox("Yes was pressed")
elseif (rc == 8) then
wx.wxMessageBox("No was pressed")
else
wx.wxMessageBox("Did not work")
end
end
---------------------------------------------------------------


Thanks,
Bill

277
Mach4 General Discussion / Re: load g code
« on: August 10, 2020, 11:49:44 AM »
Swifty,

I did not notice that.

Thanks,

Bill

278
Mach4 General Discussion / Re: load g code
« on: August 10, 2020, 10:03:34 AM »
Here is the code I ended up with.
At the end is some code that pops up a message box to let the operator know that the file is outside the machine limits if they set Home All.

Code: [Select]
---------------------------------------------------------------
-- Load file function.
---------------------------------------------------------------
function LoadCCIFile()

inst = mc.mcGetInstance();
-- create the wxFrame window
mainframe = wx.wxFrame( wx.NULL,          -- no parent
wx.wxID_ANY,          -- whatever for wxWindow ID
"DummyFrame", -- frame caption
wx.wxDefaultPosition, -- place the frame in default position
wx.wxDefaultSize,      -- default frame size
wx.wxDEFAULT_FRAME_STYLE ) -- use default frame styles

-- create a panel in the frame
panel = wx.wxPanel(mainframe, wx.wxID_ANY)
--We are not going to show it but we need to have this to use the File dialog

local file = wx.wxFileDialog(panel, "Select Cutting File", "", "", "All files (*.*)|*.*|CNC files (*.cnc)|*.cnc|Tap files (*.tap)|*.tap|Text files (*.txt)|*.txt",
wx.wxFD_SAVE,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
if(file:ShowModal() == wx.wxID_OK)then
local path = file:GetPath()   
mc.mcCntlLoadGcodeFile(inst, path);
--regenerate toolpath
mc.mcToolPathGenerate(inst)
end
--if machine homed check if file larger than soft limits
hregMHmd = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
valMHmd = mc.mcRegGetValue(hregMHmd)
if (valMHmd == 1) then
MaxX = mc.mcAxisGetSoftlimitMax(inst, 0)
MaxY = mc.mcAxisGetSoftlimitMax(inst, 1)
hregPathXMax = mc.mcRegGetHandle(inst, 'core/inst/PathXmax')
PathXmax = mc.mcRegGetValue(hregPathXMax)
hregPathYMax = mc.mcRegGetHandle(inst, 'core/inst/PathYmax')
PathYmax = mc.mcRegGetValue(hregPathYMax)

MinX = mc.mcAxisGetSoftlimitMin(inst, 0)
MinY = mc.mcAxisGetSoftlimitMin(inst, 1)
hregPathXMin = mc.mcRegGetHandle(inst, 'core/inst/PathXmin')
PathXmin = mc.mcRegGetValue(hregPathXMin)
hregPathYMin = mc.mcRegGetHandle(inst, 'core/inst/PathYmin')
PathYmin = mc.mcRegGetValue(hregPathYMin)

if (PathXmax >= MaxX) or (PathYmax >= MaxY) or (PathXmin <= MinX) or (PathYmin <= MinY) then
wx.wxMessageBox("Cut file is outside cut area.\nContinuing may damage machine.")
end
end


end


279
Mach4 General Discussion / Re: load g code
« on: August 10, 2020, 08:55:51 AM »
Craig,

Thank you.

Bill

280
Mach4 General Discussion / load g code
« on: August 07, 2020, 10:20:39 AM »
The Load G Code button brings up a screen to select the file. (Gcode Load action)
I want to do the same thing using Lua script.
The mc.CntlLoadGcodeFile requires the file name.

Bill