Macros accessing User Variables set in G Code

If you have a question about the software please ask it here.

Macros accessing User Variables set in G Code

Postby GaryLa » Thu Apr 08, 2021 11:44 am

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 }
GaryLa
 
Posts: 76
Joined: Thu May 30, 2019 11:30 pm

Re: Macros accessing User Variables set in G Code

Postby dezsoe » Thu Apr 08, 2021 12:02 pm

Yes, exec.Getvar and exec.Setvar. See Macro_capability_detailed.htm in your UCCNC\Documentation folder for details.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macros accessing User Variables set in G Code

Postby GaryLa » Thu Apr 08, 2021 12:15 pm

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?
GaryLa
 
Posts: 76
Joined: Thu May 30, 2019 11:30 pm

Re: Macros accessing User Variables set in G Code

Postby ger21 » Thu Apr 08, 2021 12:55 pm

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.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros accessing User Variables set in G Code

Postby Battwell » Thu Apr 08, 2021 1:09 pm

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)
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 867
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macros accessing User Variables set in G Code

Postby dezsoe » Thu Apr 08, 2021 1:52 pm

These functions work with all the #variables, 0..5999. Reserved are 5060..5066 and 5399. (I've searched the manual for "#".)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Ask a question from support here

Who is online

Users browsing this forum: Google [Bot] and 44 guests