Page 1 of 1

Macros - G68 Rotation

PostPosted: Sat Jul 01, 2017 5:06 pm
by Robertspark
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,

Re: Macros - G68 Rotation

PostPosted: Sat Jul 01, 2017 11:39 pm
by dezsoe
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.

Re: Macros - G68 Rotation

PostPosted: Sat Jul 01, 2017 11:58 pm
by cncdrive
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.

Re: Macros - G68 Rotation

PostPosted: Sun Jul 02, 2017 12:03 am
by Robertspark
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.