Page 1 of 1
Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 11:44 am
by GaryLa
Is it possible to access the # variables from a macro?
To minimize G Code, I'd like to set a value such as #1 = 1.0 in G code and then have a macro access it.
Example:
- Code: Select all
#1 = 1.0
M8000 //macro access user variable 1
M8000
M8000
Instead of:
- Code: Select all
M8000 { N1.0 }
M8000 { N1.0 }
M8000 { N1.0 }
Re: Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 12:02 pm
by dezsoe
Yes, exec.Getvar and exec.Setvar. See Macro_capability_detailed.htm in your UCCNC\Documentation folder for details.
Re: Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 12:15 pm
by GaryLa
Thanks.
That's what I was thinking, but I've never used getvar/setvar and wasn't sure if their purpose was to set only some UCCNC internal variables.
So these two functions only access the "# internal variables" from #0 to #999 and the documented variables #5060 through #5066?
Re: Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 12:55 pm
by ger21
They can use and access any # variable.
One issue though, is that you don't know which variables are used by UCCNC, or even other running plugins.
It would be nice if CNC Drive could publish a list of used Var #'s.
Re: Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 1:09 pm
by Battwell
gerry. same goes for anyone that writes macros.
i usually put a list of var numbers ive used in a macro in the top header now. (so i can cross reference later etc)
Re: Macros accessing User Variables set in G Code
Posted:
Thu Apr 08, 2021 1:52 pm
by dezsoe
These functions work with all the #variables, 0..5999. Reserved are 5060..5066 and 5399. (I've searched the manual for "#".)