Retrieve active profile file name?

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Retrieve active profile file name?

Postby evanevery » Sun Sep 08, 2024 1:30 am

Anyone know how to retrieve the full pathname of the currently active profile file from a macro?

I'ld like to be able to share/update some settings from within a private section in the profile with an external executable...
evanevery
 
Posts: 20
Joined: Tue Jan 11, 2022 3:57 pm

Re: Retrieve active profile file name?

Postby cncdrive » Wed Oct 16, 2024 10:54 pm

You could use the exec.macroprofilename; variable, but it only gives the name of the profile.
You could also use the Application.StartupPath.ToString(); to get the path of the UCCNC, so you could edit them together.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Retrieve active profile file name?

Postby evanevery » Thu Oct 17, 2024 1:40 pm

So I tried a very simple macro:

Code: Select all
MessageBox.Show("Macro ID: " + this.macronumber);

MessageBox.Show("Profile Name: " + exec.macroprofilename);

MessageBox.Show("UCCNC Path: " + Application.StartupPath.ToString());


and I get this error:

Code: Select all
UCCNC macro compiler error log file
--------------------------------------
Last error dated: 10/17/2024 8:35:12 AM
In macro: M2000
--------------------------------------
CS1061 | in line: 10 | error text: 'Macroclass' does not contain a definition for 'macronumber' and no extension method 'macronumber' accepting a first argument of type 'Macroclass' could be found (are you missing a using directive or an assembly reference?)
CS1061 | in line: 12 | error text: 'UCCNC.Executer' does not contain a definition for 'macroprofilename' and no extension method 'macroprofilename' accepting a first argument of type 'UCCNC.Executer' could be found (are you missing a using directive or an assembly reference?)
--------------------------------------


So, the "Application.StartupPath.ToString()" works - but the "this.macronumber" and "exec.macroprofilename" does not. (I tried them both as a function (appending "()") and as a variable (as shown))

Am I missing something?
evanevery
 
Posts: 20
Joined: Tue Jan 11, 2022 3:57 pm


Return to Macros

Who is online

Users browsing this forum: Bing [Bot] and 10 guests