Macros - G68 Rotation

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

Macros - G68 Rotation

Postby Robertspark » Sat Jul 01, 2017 5:06 pm

With regards to G68 - Rotation

Once set, is there any way to find out what the rotation setting is (point of rotation and angle)?

I ask this because if for example I am running a macro which has a different G68 setting, I'd like to be able to establish if G68 is set

If it is set, I'd like to be able to store the current settings

then clear and reset the G68 rotation angle to the macro setting

carry out the macro operation

reset to the original G68 rotation (if it was set).

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

Re: Macros - G68 Rotation

Postby dezsoe » Sat Jul 01, 2017 11:39 pm

Yes, you can find it in the Activemodal (877) field. It's tricky to extract the values, but not impossible:

Code: Select all
string Activemodal = AS3.Getfield(877);                                         // Field 877: Activemodal
string Params = "";
string temp = "";

string[] WordSeparator = new string[] {"|"};
string[] ParamSeparator = new string[] {","};

string[] Modals = Activemodal.Split(WordSeparator, StringSplitOptions.None);
string[] G68Params;

foreach (string s in Modals)
{
  if (s.Substring(0, 3) == "G68")
    Params = s;                   
}

if (Params == "")
  temp = "G69 (not rotated)";
else
{
  Params = Params.Substring(4, Params.Length - 5);
  G68Params = Params.Split(ParamSeparator, StringSplitOptions.None);
  temp = "G68 A" + G68Params[0] + " B" + G68Params[1] + " " + G68Params[2];
}

MessageBox.Show(temp);

As you see, first you need to split the modals to get strings including "G69" or "G68[aa.a,bb.b,Rrr.r]". If there is a string with "G68" in the first 3 letters, then you have to cut the beginning and the end of this string and split again. The first two parameters (A and B) are only numbers, the third has the letter "R" also in it.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macros - G68 Rotation

Postby cncdrive » Sat Jul 01, 2017 11:58 pm

The only issue with this code is that the values there are truncated to 1 digit only, so it is not very precise.
I will make a GetRotate function in the next release so you could get the precise values.
And for temporarily you may read these variables of the exec object:

public double rotX;
public double rotY;
public double rotAngle;

But please use these only as a temporary solution.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: Macros - G68 Rotation

Postby Robertspark » Sun Jul 02, 2017 12:03 am

dezsoe, thank you so much for your hard work, I was not expecting that, it is very much appreciated.

Balazs, thanks very much, very much appreciated.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm


Return to Macros

Who is online

Users browsing this forum: No registered users and 10 guests