Hello Guest it is March 28, 2024, 09:44:43 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 - SwiftyJ

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 »
171
Instead of 'Up' and 'Down', use '0' and '1'

172
mc.mcMotorGetAxis() returns two things, the axis ID and a return code.
 
Your code should be like this, then you can check each variable..

Code: [Select]
local axisID, rc = mc.mcMotorGetAxis(inst,Spindle)

173
Another few things,  the API mc.mcAxisGetMotorId requires the following..
Code: [Select]
motorId, rc = mc.mcAxisGetMotorId(
number mInst,
number axis,
number childId)

You are missing the child Id.
 
It also returns the motorId as a number so in your if statement you have
Code: [Select]
if AxisZ == "2"
this should be
Code: [Select]
if AxisZ == 2


174
Mach4 General Discussion / Re: Passing a value in function call
« on: March 13, 2020, 11:26:15 AM »
The issue is that you have single quotation marks around percent. Lua recognises anything enclosed with " " or ' ' as strings so its trying to set it to the string 'percent'. If passing the param to the function as a number you'll have to use the tostring() function as scr.SetProperty requires strings.

Try this..
Code: [Select]
function JogRatePercent(percent) --This function sets the jog rate
   scr.SetProperty("droJogRate", "Value", tostring(percent))
end

Ideally you should use the API call mc.mcJogSetRate rather than using the scr call. If you haven't found the list of these API's yet check inside the Docs folder in the Mach4 directory, Mach4CoreAPI.chm.

wx.wxMessageBox() also only accepts strings.

175
Check to see if machipc.dll and screenipc.dll are in the Modules folder. If not, I believe that is the problem

176
Mach4 General Discussion / Re: Tool change type cant change and save
« on: February 27, 2020, 03:19:53 PM »
I had this issue a while ago. I think I had to replace the ‘parameters.ini’ file in the Profiles folder

177
Mach4 General Discussion / Re: Create elements in Mach 4
« on: February 12, 2020, 02:53:21 AM »
To use this code in the Lua Panels in Mach4, you must use the Mach4 Panel as the parent.
So change this line
UI.MyPanel1 = wx.wxPanel (wx.Null, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize( 500,300 ), wx.wxTAB_TRAVERSAL )
to
UI.MyPanel1 = mcLuaPanelParent

178
Mach4 General Discussion / Re: How to determine enabled/disabled state?
« on: February 12, 2020, 02:46:33 AM »
If your aim is to prevent yourself pressing buttons that require Mach4 to be enabled, another option is to select the 'Enable with Machine' property for the button. When this is selected the button will disable when Mach is disabled, and enable when Mach is enabled.


179
Mach4 General Discussion / Re: How do determine if Gcode move is complete?
« on: February 10, 2020, 03:01:37 AM »
You can use the following code to achieve what you want using a coroutine as Katz pointed out. You can move the function into the screen load script if you prefer. The standard mach screens use a coroutine on the 'Reference All' button so you can see how that is done also.

Modify the g-code string to suit your need. If the machine is stopped during the move, the message will still appear so you may want to check if the axis positions matches the commanded before showing the message?

Code: [Select]
wait = coroutine.create(function()
local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "g01 x100 f1000")
coroutine.yield()
wx.wxMessageBox("Move complete")
end)

180
Mach4 General Discussion / Re: Playing a sound in a script?
« on: February 07, 2020, 02:44:06 AM »
I think you need to add a flag to Play(), these are the options available.

wxSOUND_SYNC: Play will block and wait until the sound is replayed.
wxSOUND_ASYNC: Sound is played asynchronously, Play returns immediately.
wxSOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops until another sound is played, Stop() is called or the program terminates.

I have had it working with just wxSOUND_LOOP. So in your case it would be logoff:Play(wx.wxSOUND_LOOP) and then you have to use logoff:Stop() to stop it.

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 »