G68 alignment macro

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

Re: G68 alignment macro

Postby Delco » Tue Jan 21, 2020 7:28 am

Thank you :) tested it and it works great
Delco
 
Posts: 391
Joined: Tue Apr 02, 2019 4:23 am

Re: G68 alignment macro

Postby Delco » Tue Jan 21, 2020 8:27 am

in the process of trying to understand the macros ,

double angle = AS3.Getfielddouble(2715); // Angle probe result from probe screen ( i now understand the label number is also the variable location ? (2715)

exec.AddStatusmessage("Rotate: G68 A0 B0 R" + angle.ToString("F6")); // this writes the message to the screen

exec.Code("G68 A0 B0 R" + angle.ToString("F6")); // Rotate at 0,0 with angle degrees
while (exec.IsMoving());


but where is " +angle.ToString("F6") " coming from ??? my logic brain would have thought it should have been "double angle" ??
Delco
 
Posts: 391
Joined: Tue Apr 02, 2019 4:23 am

Re: G68 alignment macro

Postby dezsoe » Tue Jan 21, 2020 9:54 am

"double" is the type of the "angle" variable. It is a numeric type, so you have to convert it to string to add it to the other string ("G68..."). The .ToString() function has the "F6" parameter, which makes a formatted string with 6 decimals. See: Types and variables.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: G68 alignment macro

Postby Delco » Tue Jan 21, 2020 10:27 am

Thank you , that makes sense :)
Delco
 
Posts: 391
Joined: Tue Apr 02, 2019 4:23 am

Re: G68 alignment macro

Postby cncdrive » Tue Jan 21, 2020 11:52 am

Learn the C# language syntax if you want to understand the macros.
It is a very popular programming language, so you can find lots of books online and in book stores too.
cncdrive
Site Admin
 
Posts: 5197
Joined: Tue Aug 12, 2014 11:17 pm

Re: G68 alignment macro

Postby Delco » Wed Jan 22, 2020 5:49 am

I have ordered one online , it would be nice to have a heap of fully commented macros on the forum to learn from.
Delco
 
Posts: 391
Joined: Tue Apr 02, 2019 4:23 am

Re: G68 alignment macro

Postby Robertspark » Wed Jan 22, 2020 10:16 am

:lol: :roll:
there are many working macros in here:
viewforum.php?f=15

No they are not normally commented, but they do all have a listed purpose and with patience, diligence and some perseverance you should be able to learn how they work, and the C# syntax works + UCCNC methods / functions and variables that make them work.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: G68 alignment macro

Postby Delco » Wed Jan 22, 2020 11:12 am

Been there , like I said it would be nice to have a section where documented and commented macros are located so as to learn how they work.
Delco
 
Posts: 391
Joined: Tue Apr 02, 2019 4:23 am

Re: G68 alignment macro

Postby Robertspark » Wed Jan 22, 2020 8:04 pm

I can't help..... :D

Image

Image

:shock:

How about having a go at putting (or even starting to put) something together for the benefit of the community?

From the point of view of a new user starting out and demonstrating what is important for a new user to know to start out....

It does take time to figure this stuff out and even when you think you have you have just figured out what you needed to know until the next task comes along and throws something at you that you did not know you needed to know.....

If you ask specific questions I'm sure someone will help you out.... but simply asking for ...

it would be nice to have a section where documented and commented macros are located so as to learn how they work.


That is a LOT of work to do..... so unless you are willing to step up to the plate then it'll never be done as its of limited benefit to a few.....

I put a fair bit of comments in my macros but only so I can remember how I intended them to work months later when I need to find out why something is not working or to adapt if for something else.... its actually for my own benefit not really for anyone else unless I'm trying to help out someone with something.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: G68 alignment macro

Postby beefy » Wed Jan 22, 2020 8:39 pm

Delco wrote:Been there , like I said it would be nice to have a section where documented and commented macros are located so as to learn how they work.


As Balazs said, learn the language, but also study the documentation (Macro_capability_detailed.htm inside the UCCNC folder) on the UCCNC C# commands, and you'll pretty much understand what the macro is doing as you read it.

I also recommend studying all the other documentation in that folder, as that will help you with understanding what the commands in a macro are referring to (buttons, LEDs, DROs, etc).

Most macros are relatively simple, so once you learn the above, many macros will be easy to figure out.

It's true what Rob said, the guys that write macros are generally not doing so with a view to teach others who have not yet learnt C#, and the UCCNC documentation, and Cncdrive have enough on their plate already. That leaves forum members, but unless someone has nothing better to do than go through macros commenting them in detail for others benefit, who will do it ??
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

PreviousNext

Return to Macros

Who is online

Users browsing this forum: No registered users and 4 guests