Page 1 of 3

Show media files on screen with M130 like HAAS

PostPosted: Mon Apr 09, 2018 7:51 pm
by Blaise
Hi all!

Have you seen how next gen HAAS control can show media files on screen using M130.
This can be used to show the machinist where to place the work offset on a part or how to flip a part etc...
https://youtu.be/_FxHfVKSOcs

This could be fun to have with UCCNC!

Just throwing it out there!

- Blaise

Re: Show media files on screen with M130 like HAAS

PostPosted: Mon Apr 09, 2018 9:03 pm
by dezsoe
30 minutes coding for fun! :)

G-code:
Code: Select all
G0 X0 Y0 Z0
M130 (C:\UCCNC\Flashscreen\BMP\Defaultscreenset\cncdrive_logo.png)
G0 X20
M30

M130.txt:
Code: Select all
string myLine = exec.Getcurrgcodelinetext();
string param = "";
int lineNo = exec.Getcurrentgcodelinenumber();
int posF = 0;
int posL = 0;
string work = "";

if (myLine != null)
{
  posF = myLine.IndexOf("(");
  if (posF != -1)
  {
    posL = myLine.LastIndexOf(")");
    if (posL > posF)
      param = myLine.Substring(posF + 1, posL - posF - 1);
  }
}

if (param == "") return;

MyForm = new Form();
MyForm.Size = new System.Drawing.Size(800, 600);
MyForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
MyForm.Text = "Show media file - " + param;
MyForm.AutoSize = true;

Button button1 = new Button();
button1.Size = new System.Drawing.Size(75, 23);
button1.Location = new System.Drawing.Point(355, 526);
button1.Text = "Close";
button1.Click += new EventHandler(button1_Click);

PictureBox pictureBox1 = new PictureBox();
pictureBox1.Size = new System.Drawing.Size(760, 508);
pictureBox1.Location = new System.Drawing.Point(12, 12);
pictureBox1.ImageLocation = param;
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;

MyForm.Controls.Add(button1);
MyForm.Controls.Add(pictureBox1);

MyForm.ShowDialog();

#Events

Form MyForm;

void button1_Click(object sender, EventArgs e)
{
  MyForm.Close();
}

Result:
M130.png

Re: Show media files on screen with M130 like HAAS

PostPosted: Mon Apr 09, 2018 9:25 pm
by Blaise
Wow! This is crazy cool and crazy fast!!!!
Can't wait to try this!

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 4:14 am
by Blaise
Dezsoe,

I tried it with no success. I placed “M130.txt” in my profile macro folder. Restarted UCCNC and loaded the suggested gcode but I only got an error with the M130 macro. I never tried macros before and I am new with UCCNC so if I missed something obvious please be indulgent!

- Blaise

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 6:14 am
by dezsoe
Blaise,

What kind of error do you get? I forgot to write that the minimum version to run this macro is 1.2102. If you get a file related error then check if the file in the remark () exists.

Terry,

Yes, we had a screenshot (and many other screenshots) without any code. :)

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 12:30 pm
by Blaise
I have version 1.2047

Capture.PNG


- Blaise

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 1:27 pm
by dezsoe
With that version it will not work. The function for getting the current code line was introduced in 1.2101, but it had an error which was fixed in version 1.2102, so the minimum version is 1.2102.

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 2:27 pm
by Sword
I haven't tried this yet, but just a thought I had when first reading it. Vectric products can save a 'Job Sheet' in html format.... Could this somehow look for this file and if present, open it for viewing? Would be kind of nice if it opened in a stand alone window instead of a browser in this case. Possibly adding a line to your PostP file that would ask if you would like to see it or not when loading a file. Just some thoughts on making use of this. ;)

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 2:37 pm
by Blaise
With Fusion 360 when using the Haas post, it does exactly that! You get the option to use the M130 macro and it is checked by default, it will use the setup image from the setup sheet! I was planing to find the related lines of code in the Haas post and apply them to the UCCNC post in Fusion.

Where can I find the 1.2102 version? I couldn’t find it on the CNCDRIVE website.

Thanks!

- Blaise

Re: Show media files on screen with M130 like HAAS

PostPosted: Tue Apr 10, 2018 3:01 pm
by dezsoe
The 1.21xx versions are test versions, so use them only for testing, not in production. The test versions can be found on this forum here.