Hello Guest it is April 19, 2019, 05:08:04 PM

Author Topic: Trying to get the current Gcode line #  (Read 3023 times)

0 Members and 1 Guest are viewing this topic.

Online BR549

*
  •  6,863 6,863
    • View Profile
Trying to get the current Gcode line #
« on: December 05, 2014, 01:35:35 AM »
I am trying to get the current Gcode line Number. The book is not really clear about the parameters required.

ANY Ideas on the call ?

 buff, rc         = mc.mcCntlGetGcodeLine(number mInst, number LineNumber)
        --What Gcode line number is the interpreter on at present

Mach4 errors out on everything I tried . It says the call requires (number,number,string,number) but that does not make sense as you are looking for the number.

I tried LineNumber as the book says thinking is was an internal Parm but it is <nil> not a good param.

(;-) TP

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Trying to get the current Gcode line #
« Reply #1 on: December 05, 2014, 02:47:51 AM »
whats the full code you used.

on my playing today I found there is a order stuff needs to be in.

and you more than likely know this needs to be at the start, everything I did today it did anyway
local inst = mc.mcGetInstance();

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Trying to get the current Gcode line #
« Reply #2 on: December 05, 2014, 06:51:19 AM »
Terry,

That call returns a the Line of G-Code at the line number you pass.
i.e. if you have "G0 X1" on linenumber 10, then the "buffer" (string buffer) would
have:  'G0 X1' in it.

To get the G-code line number that is currently executing use:

local LineNum, rc = mc.mcCntlGetGcodeLineNbr(inst);

NOTE:  this returns a ZERO based index, so if your "3rd" line in the gcode window is highlighted blue, then the LineNum value will be 2

Scott



Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Trying to get the current Gcode line #
« Reply #3 on: December 05, 2014, 06:58:48 AM »
pulled this right out of one of the plc scripts

local TotalLines = mc.mcCntlGetGcodeLineCount(inst);
local GcodeCurrentLine = mc.mcCntlGetGcodeLineNbr(inst);
local GcodePercent = (GcodeCurrentLine/TotalLines) * 100;

scr.SetProperty('droTotal', 'Value', tostring(TotalLines+1));
scr.SetProperty('droPercent', 'Value', tostring(GcodePercent));
scr.SetProperty('guageGcode', 'Value', tostring(GcodePercent) );

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Trying to get the current Gcode line #
« Reply #4 on: December 05, 2014, 07:21:17 AM »
Terry, daniellyall, (and others that may be interested),

You can also "Pull up the List" of available mc.mc codes in the mcLua scripter.....

When your're wanting to look for something, but are not quite sure what it is called.

in the scripter type:   "mc.mcC"  (see screen shot attached)

When you get to the "C" of the above, the "autocomplete" will appear with a list of all the commands, you can then scroll/read down them to find one that your looking for. MOST of the functions names are "Self documenting".

When you find the one you want, click it to highlight it (blue), then hit your Tab Key, it will insert it.
NOTE: it will only insert the name, and NOT the function parentheses!!
you will also have to insert the parameters that go in the parentheses, your self as well.

the easiest way to see what those are (IMHO), is to also have open the mcLua scripting reference manual, copy the command from your scripter, and paste it into you "find" box of the open manual document. When it finds it, you can then see what params it needs, and what those params are/do.

Scott

Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Trying to get the current Gcode line #
« Reply #5 on: December 05, 2014, 01:58:49 PM »
thanks for that scott

Online BR549

*
  •  6,863 6,863
    • View Profile
Re: Trying to get the current Gcode line #
« Reply #6 on: December 05, 2014, 08:46:04 PM »
Thansks ALL I got the LIne# working. The odd thing is   The DRO that gives you the current line and the call to get the current line gives you 2 different values (;-) One is 1 based and the other 0 based.

NOW does anyone know IF the DRYRUN  feature works. I cannot get it to do anything in SIM()

AND I cannot get the goto page function to work either.
Re: Trying to get the current Gcode line #
« Reply #7 on: December 07, 2014, 10:26:51 PM »
Dry Run is working well. It is the replacement for RunFromHere is you want more control.  Other wise you can use the one from the Actions drop down in the screen editor.
Andrew
MachMotion

Online BR549

*
  •  6,863 6,863
    • View Profile
Re: Trying to get the current Gcode line #
« Reply #8 on: December 07, 2014, 11:44:07 PM »
I do not see an action pulldown selection for DRYRUN and scritping the DRYRUN feature does not run either. Tried from a button script AND from the LUA editor.

That is in the SIM().

(;-) TP

Online BR549

*
  •  6,863 6,863
    • View Profile
Re: Trying to get the current Gcode line #
« Reply #9 on: December 08, 2014, 12:19:28 AM »
OKEY DOKEY, I was able to make Dryrun RUN. You just have to be smarter that the control (;-)

(;-) TP