Macros for Dummies

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

Macros for Dummies

Postby spumco » Wed Oct 11, 2017 5:06 am

Now that I've mostly learned how not to crash tools in to my parts and fixtures, I've decided that it's time to learn about macros.

While I understand the concept of a macro, I'm utterly ignorant of the mechanics. I'm tired of macro examples posted here appearing to me like gibberish.

Does anyone have a suggestion for a book, web site, or other resource on how to write, edit, or otherwise learn how to deal with macros? While I'd like a general guide, my primary intent is to write/edit macros in UCCNC so if there is something specific to the macro language used by UCCNC that would be very helpful.

Thanks much,
Spumco
spumco
 
Posts: 115
Joined: Mon Oct 03, 2016 10:10 pm

Re: Macros for Dummies

Postby cncdrive » Wed Oct 11, 2017 7:29 am

Hi,

The programming language of macros in the UCCNC is C# (CSharp).
It is around the 4.-5. most popular programming language of the world, so there are lots of books available and also online help and tutorials etc.
Googling 'C# books" gives several thousands of useful links to books and stores etc.
C# is a C based programming language. It is very similar to C language, but ofcourse there are differences to Ansi C and C++, so better to read articles and books directly about C# instead of C or C++.
And you could practice C# programming in general with e.g. Visual Studio. The community editions can be downloaded and used free of charge from Microsoft's website, just google it...
So, that's about the programming language.

The other thing is the functions available for macros in the UCCNC, you can find the prototypes of those in the UCCNC installation, in the UCCNC/Documentation folder.
Also Rob put a nice summary manual together: https://drive.google.com/drive/folders/ ... kdfQWRaYTg
cncdrive
Site Admin
 
Posts: 1381
Joined: Tue Aug 12, 2014 11:17 pm

Re: Macros for Dummies

Postby ger21 » Wed Oct 11, 2017 10:52 am

I use this style with NotePAD++, which makes the macros a lot easier to read.
viewtopic.php?f=11&t=101

I recommend studying existing macros. Go through them one line at a time, and compare each line to the reference docs. You'll see that most UCCNC functions are done with a single line of code, until you get into more advanced C# stuff.
Gerry
UCCNC 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 749
Joined: Sat Sep 03, 2016 2:17 am

Re: Macros for Dummies

Postby Robertspark » Wed Oct 11, 2017 11:03 am

I need to update that notepad plugin (new ucccnc functions not listed / wont change colour)...

I have and use this book a lot
https://www.amazon.co.uk/Beginning-Visu ... 1118314417


bought through here....
https://www.abebooks.co.uk/servlet/Sear ... &kn=&isbn=


I've got the dummies C# book too as that was pennies, but it's not that good and I find the one listed above the best.

because uccnc is .net 2.0 (read DOT NET TWO POINT 0), you don't need the latest and greatest published book as some of the features listed for .net 4.5 wont work....
Rob

Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
UC400eth, UC300eth, UCCNC v1.2046, Neuron Lite.
UCCNC Macro Manual
Robertspark
 
Posts: 599
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Macros for Dummies

Postby Robertspark » Wed Oct 11, 2017 11:31 am

With regards to this manual Balazs posted, although it says v 1.2039, there is only one new item between that and the current development version which is an LED / button from memory, so consider it as current.

The way to use the manual is both via the index (as if you click on any function it will take you to the page).

I wrote it so you can just copy the example code into notepad ++ and modify the parameters (field, LED, button etc) and it will work fine

Also look in the uccnc profile folder, and you'll find the example macros, if you look at the ones around M200 onwards they provide some really good examples which you can cut and paste to form your adapted macro
Rob

Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
UC400eth, UC300eth, UCCNC v1.2046, Neuron Lite.
UCCNC Macro Manual
Robertspark
 
Posts: 599
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Macros for Dummies

Postby Robertspark » Wed Oct 11, 2017 2:51 pm

Oh yeah, just remembered, have a look in the UCCNC TOOL BOX section of the forum, as there is quite a few macros and examples of working macros in there which you can cut and paste and adapt

viewforum.php?f=15
Rob

Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
UC400eth, UC300eth, UCCNC v1.2046, Neuron Lite.
UCCNC Macro Manual
Robertspark
 
Posts: 599
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: Macros for Dummies

Postby spumco » Wed Oct 11, 2017 9:21 pm

Thanks everyone. I'm sure I'll be back for more help with this.

-Spumco
spumco
 
Posts: 115
Joined: Mon Oct 03, 2016 10:10 pm

Re: Macros for Dummies

Postby 1JUMPER10 » Fri Oct 13, 2017 12:32 am

I have a question that is appropriate for this thread seeing as how the title describes me :D

I downloaded Robertspark M1020 macro. It checks the axis limits of a loaded G-code file. Where in UCCNC file structure do I put this macro? And to call it, do I just type "M1020" in the MDI?
Dumb question I know. Be kind... :lol:
1JUMPER10
 
Posts: 48
Joined: Tue Oct 04, 2016 1:54 am

Re: Macros for Dummies

Postby cncdrive » Fri Oct 13, 2017 1:04 am

You should copy the macros in the UCCNC/Profiles/Macro_yourprofile folder, where "yourprofile" means the name of the profile you running. Each profile has it's own folder with it's own macro files.
Then you can call the macro from MDI and g-code file with the macro number, like M1020.

You can also attach macros to buttons on the screen.
Just make a button or copy and existing one with the screen editor and adjust the buttonnumber parameter to the range between 20000 and 21999 and make your macro number also in this range.
This range of macros are dedicated to macro calls from buttons presses.
Then pressing the button will execute the same number of macro as the buttonnumber parameter.
cncdrive
Site Admin
 
Posts: 1381
Joined: Tue Aug 12, 2014 11:17 pm

Re: Macros for Dummies

Postby Greolt » Fri Oct 13, 2017 5:37 am

Robertspark wrote:I need to update that notepad plugin (new ucccnc functions not listed / wont change colour)...

I have and use this book a lot
https://www.amazon.co.uk/Beginning-Visu ... 1118314417


I downloaded that book as an ebook. It suggests getting Visual Studio 2012 Express

If only wanting to write e few simple macros for UCCNC, do you think that is necessary?

I did try your plugin for Notepad++ But could not get rid of the black highlighting (you may like a black background but I hate it)

It kept reverting to that no matter what file I opened. Ended having to uninstall notepad and reinstall to get rid of it. :(
Greolt
 
Posts: 63
Joined: Sun Sep 04, 2016 6:22 am

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 1 guest