Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: BR549 on December 05, 2014, 01:35:35 AM

Title: Trying to get the current Gcode line #
Post by: BR549 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
Title: Re: Trying to get the current Gcode line #
Post by: dude1 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();
Title: Re: Trying to get the current Gcode line #
Post by: poppabear 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



Title: Re: Trying to get the current Gcode line #
Post by: Ya-Nvr-No 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) );
Title: Re: Trying to get the current Gcode line #
Post by: poppabear 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

Title: Re: Trying to get the current Gcode line #
Post by: dude1 on December 05, 2014, 01:58:49 PM
thanks for that scott
Title: Re: Trying to get the current Gcode line #
Post by: BR549 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.
Title: Re: Trying to get the current Gcode line #
Post by: MachMotion Development Team 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.
Title: Re: Trying to get the current Gcode line #
Post by: BR549 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
Title: Re: Trying to get the current Gcode line #
Post by: BR549 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
Title: Re: Trying to get the current Gcode line #
Post by: dude1 on December 08, 2014, 12:56:42 AM
BR549 are you going to share any of the code you have come up with