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 cncdrive » Wed Jan 29, 2020 7:26 am

C# is about the 5th most popular programming language on the world.
So, there are lots of books, tutorials etc. stuff out there to learn from.

Our thinking is that we point you the information you need and if you're open to learn then you can learn it like a good student.
If you are not open to learn then you are a bad student and then you will never learn it, no matter how we want to help.
We think and help like this because we know that to learn things like this the only way is if you're open to learn yourself. We point the informations out for you...
cncdrive
Site Admin
 
Posts: 3206
Joined: Tue Aug 12, 2014 11:17 pm

Re: G68 alignment macro

Postby dezsoe » Wed Jan 29, 2020 9:55 am

Hi Delco,

I made some changes to the macro. Staying with the example, let's call it M1234. Now you can measure the angle and then run "M1234 Q1". This will save the angle for later use. (It's only in the memory, so if you exit UCCNC the value will be lost.) You do all your stuff and then call "M1234 Q2" which will rotate the coordinates by the saved angle. Also, you can rotate any time, so if you need to measure something else then just call G69 to turn off rotation, do your stuff and call "M1234 Q2" again.

Code: Select all
if (Qvar == null)
{
  return;                                                                       // No Q parameter -> exit
}

switch (Convert.ToInt32(Qvar))
{
  case 1:                                                                       // Q = 1
    angle = AS3.Getfielddouble(2715);                                           // Save angle probe result from probe screen
    exec.AddStatusmessage("Angle saved: " + angle.ToString("F6"));              // Report the result
    break;
  case 2:                                                                       // Q = 2
    exec.AddStatusmessage("Rotate: G68 A0 B0 R" + angle.ToString("F6"));        // Report the rotation
    exec.Code("G68 A0 B0 R" + angle.ToString("F6"));                            // Rotate at 0,0 with angle degrees
    while (exec.IsMoving());                                                    // Wait for the G68 to finish
    break;
}

#Events

static double angle = 0.0;                                                      // Angle probe result from probe screen
dezsoe
 
Posts: 1002
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: G68 alignment macro

Postby beefy » Wed Jan 29, 2020 11:34 am

Delco wrote:This C# stuff is like some secret club , first forum I have ever been on where posters just bag you out as they have more experience ......................................

I like uccnc but cant say its a helpful site....

I will just crawl back into my hole now and get back to liking my hobby


So, people are "bagging you out" because they have more experience !!!!!!!!!! ?????????? What planet are you on.

Do some of us a favour here and go crawl back into your hole as you said it. The real problem is you want all the answers before you even learn anything.

Do you give a simple thanks for when I answered your questions on the macro, and explained some things about programming. No you just come back bitching and groaning. No point teaching you how to fish, so I for one will make sure I don't ever help you again. I seriously hope you struggle as a result of your expectant lazy attitude.
beefy
 
Posts: 366
Joined: Mon Sep 05, 2016 10:34 am

Re: G68 alignment macro

Postby Vmax549 » Wed Jan 29, 2020 2:13 pm

HI Dezoe , Just a thought but you should save the angle value as a #var. That way it is directly useable in gcode.

Also you do not need a rotate function in teh macro as you simply use a G68 call in your gcode program.

M1045 ( Sets #1000 to teh angle value)

G68 X0Y0 R#1000 (rotates teh coord base)

Note: your macro in teh probing page SHOULD auto set a #var to teh angle value after teh macro runs. That savves having to create ANOTHER macro just to save teh value.

(;-) TP
Vmax549
 
Posts: 274
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: G68 alignment macro

Postby dezsoe » Wed Jan 29, 2020 5:17 pm

Hi Terry,

The Probe screen does not run any macros. The problem with #vars is that those vars should have the last probre result, but Delco wants to run other probes after the angle probe and before the rotation. If I store the results in #vars then a new probe will also delete them as it does on the screen. Leaving results in variables that are not current is not a safe way, I think.
dezsoe
 
Posts: 1002
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: G68 alignment macro

Postby Vmax549 » Wed Jan 29, 2020 7:02 pm

Hi Dozoe I disagree. The # var should only be overwritten IF you run teh function that calculates teh angle value . You should be able to run any other probe routine without it overwritting teh angle value and IF you run the angle routine then you wanted to change teh value.

Also the fact that UCCNC cannot probe while rotated is not a great idea. Probing out of rotation and in rotation gives you different work coord values.

Just a thought, (;-) TP
Vmax549
 
Posts: 274
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: G68 alignment macro

Postby Delco » Wed Jan 29, 2020 8:23 pm

dezsoe wrote:Hi Delco,

I made some changes to the macro. Staying with the example, let's call it M1234. Now you can measure the angle and then run "M1234 Q1". This will save the angle for later use. (It's only in the memory, so if you exit UCCNC the value will be lost.) You do all your stuff and then call "M1234 Q2" which will rotate the coordinates by the saved angle. Also, you can rotate any time, so if you need to measure something else then just call G69 to turn off rotation, do your stuff and call "M1234 Q2" again.

Code: Select all
if (Qvar == null)
{
  return;                                                                       // No Q parameter -> exit
}

switch (Convert.ToInt32(Qvar))
{
  case 1:                                                                       // Q = 1
    angle = AS3.Getfielddouble(2715);                                           // Save angle probe result from probe screen
    exec.AddStatusmessage("Angle saved: " + angle.ToString("F6"));              // Report the result
    break;
  case 2:                                                                       // Q = 2
    exec.AddStatusmessage("Rotate: G68 A0 B0 R" + angle.ToString("F6"));        // Report the rotation
    exec.Code("G68 A0 B0 R" + angle.ToString("F6"));                            // Rotate at 0,0 with angle degrees
    while (exec.IsMoving());                                                    // Wait for the G68 to finish
    break;
}

#Events

static double angle = 0.0;                                                      // Angle probe result from probe screen


Thank you and for the commenting on the code as well
Delco
 
Posts: 73
Joined: Tue Apr 02, 2019 4:23 am

Previous

Return to Macros

Who is online

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