MM204.txt >> Getactualoffset() Wzval TOZval

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

MM204.txt >> Getactualoffset() Wzval TOZval

Postby Robertspark » Sat Oct 29, 2016 9:07 am

With regards to standard macro M204.txt,

Could someone advise what the following functions and bits of code do ? Are they legacy functions of how to obtain information (fields) from screensets directly?

Thanks in advance.

line 8 - Getactualoffset() ?

line 10 - Wzval ?

line 10 - TOZval ?

line 10 - G92zval ?

line 11 - double safeZ = exec.mainform.UCsetup.UCset.Generalsettings.SafeZ;?

line 13 - double Softlimitsrelative = exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP - exec.ofc.Wzval - exec.ofc.TOZval - exec.ofc.G92zval;?
I am guessing that the exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP part of the code is another way to obtain the Axis [2] (Z-axis, positive soft limit number) from the screenset? another way would have been Getfield(42);? (Zaxissoftlimitplus)

not sure about the exec.ofc.xxxx bits.... could they have been obtained from fields too?


if(exec.mainform.UCsetup.UCset.Generalsettings.Enablesoftlimits)?
I am guessing that this is another way to check if softlimits have been enabled?

Full macro code posted below:

Code: Select all
// Go to Zero with safeZ

if(exec.GetXpos()==0 && exec.GetYpos()==0 && exec.GetZpos()==0 && exec.GetApos()==0 && exec.GetBpos()==0 && exec.GetCpos()==0)
{
  return; // if all position DROs are already zero then return
}

exec.Getactualoffset();

double safeZ = exec.mainform.UCsetup.UCset.Generalsettings.SafeZ;
double Softlimitsrelative = exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP - exec.ofc.Wzval - exec.ofc.TOZval - exec.ofc.G92zval;

if(exec.mainform.UCsetup.UCset.Generalsettings.Enablesoftlimits)
{
  if(safeZ>Softlimitsrelative)
  {
    safeZ = Softlimitsrelative;
    if(exec.GetXpos()!=0 || exec.GetYpos()!=0 || exec.GetApos()!=0 || exec.GetBpos()!=0 || exec.GetCpos()!=0)
    {
      DialogResult result = MessageBox.Show(exec.mainform.MSG.Message[45], "Confirmation", MessageBoxButtons.YesNo);
      if(result ==  DialogResult.No)
      {
        return;
      }
    }
  }
}

  while(exec.IsMoving()){}
  int originaldistancemode = exec.actualdistmode; // remember the distance mode
  int originalmodalmode = exec.actualmodal; // remember the modal mode
  exec.Code("G90"); // Set system to absolute distance mode
  exec.Wait(100);

  if(exec.GetXpos()!=0 || exec.GetYpos()!=0 || exec.GetApos()!=0 || exec.GetBpos()!=0 || exec.GetCpos()!=0)
  {
    if(exec.GetZpos()<safeZ) //Move Z only if the Z coordinate is lower than the safeZ
    {
      exec.Code("G00 Z"+ safeZ); // Move Z up to safeZ defined by user, above the zero plane
      while(exec.IsMoving()){}
    }
    exec.Code("G00 X0 Y0 A0 B0 C0"); // Move XYABC to Zero
    while(exec.IsMoving()){}

    exec.Code("G00 Z0"); // Move Z to 0
    while(exec.IsMoving()){}
  }
  else
  {
    exec.Code("G00 Z0"); // Move Z to 0
    while(exec.IsMoving()){}
  }

  exec.Code("G" + originaldistancemode); // Set system back to the original distance mode
  exec.Code("G" + originalmodalmode); // Set system back to the original modal mode



Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby ger21 » Sat Oct 29, 2016 2:35 pm

For example instead of

AS3.Getfielddouble(877)

it could be done as

GetDro(877)


I can't see any reason at all to do this.
What your asking them to do is change the language. Not a good idea at all, imo.
If you want to make it easier to understand, add comments.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby Robertspark » Sat Oct 29, 2016 3:03 pm

Hang on gents, I was merely asking about a default macro and the code within it.

I wasn't writing it, and I wasn't asking to change anything..... just asking about some of the code in it.

If is was a legacy macro writing methodology, not a problem, may need updating then?
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby ger21 » Sat Oct 29, 2016 11:05 pm

Bump...
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby cncdrive » Sun Oct 30, 2016 9:45 am

Besides BOTH versions would still work AND teh list of usefull calls is NOT a long list for the macro side Simply have teh SImple call call teh complex call and handle teh complex side of teh call. I think that is called WRAPPING ??


Terry, but you know you could also make some wrapper functions in the plugin, because you can define functions outside the macro function with the #Events word. :)
I mean you could place the wrapper functions inside the #Events and then call them from your plugin, for example:

Code: Select all

double myvar = GetDro(877);

#Events

public double getDro(int DROnumber)
{
   return AS3.Getfielddouble(DROnumber);
}

cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby Robertspark » Sun Oct 30, 2016 10:01 am

I'm with Gerry on this one, if you start changing stuff just to look more VB cypress/ mach3 you'll end up with a transition phase where no one knows what the functions are (or two sets with a legacy function...)

...if you use notepad++ and install the plugin I did it will autocomplete the function codes for you
The functions are not that long and are logical to work out what they do. Ok debugging and syntax errors can be a pain.... but use the error log (if you open it in notepad ++ on a separate tab, when you run the macro which fails in the status box, go back to notepad ++, and click on the error log tab and it will update it for you.

The functions are nowhere nearly as long mach4 lua and that syntax....
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby ger21 » Sun Oct 30, 2016 11:51 am

Can we get an answer to the original question?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby cncdrive » Sun Oct 30, 2016 5:31 pm

I advice to not use these variables, they were used in that macro when you could not query these informations from the screenset, but now all of these could be read from the screen Textfields.
The other reason why not to use these directly is because these variables are internally used by the UCCNC, these holds the offsets and if you accidentally changing the values of them can cause big problems.
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby Robertspark » Sun Oct 30, 2016 8:01 pm

MacroB, is that not just vars?

That being the case, can we not write a plugin which will populate the vars with the correct values, and pass any values back to the fields in the fields differ from the vars?

All the mathematical operators appear available for vars
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: MM204.txt >> Getactualoffset() Wzval TOZval

Postby ger21 » Sun Oct 30, 2016 8:29 pm

Being that UCCNC does NOT have conditional Gcode


Then they should add Macro B or Conditional G-Code, not add non standard features to a programming language.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 6 guests