Machsupport Forum

Mach Discussion => Mach Screens => Topic started by: Giuno85 on February 28, 2025, 04:26:25 AM

Title: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on February 28, 2025, 04:26:25 AM
Hi everyone, is it possible to create a label on the computer screen and populate it with the description of the tool in use?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on February 28, 2025, 05:50:37 AM
not directly you can make a workarround via macropump macro

code for Userlabel 123 would be:
Code: [Select]
SetUserLabel(123, GetToolDesc(GetDRO(24)))


!not tested
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 04, 2025, 12:40:25 PM
thanks for the reply.
How do I apply this variable to the label in mach screen? I see that it is not possible to put functions in labels
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 04, 2025, 12:54:44 PM
you have to make a userlabel in your screen, for example Userlabel123

and the code needs to be in macropump.m1s macro. make sure macropump is enabled in general config.
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 04, 2025, 03:09:08 PM
this way?
because i tried but it doesn't work...
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 05, 2025, 01:14:56 AM
yes this way.

for a quick test open Menu:

Operator -> VB Script Editor

then copy and paste this code into Editor

Code: [Select]
SetUserLabel(123, GetToolDesc(GetDRO(24)))
and use the green start button to run it
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 05, 2025, 07:50:18 AM
I tried to do as you say but the label doesn't change it stays like this
Am I doing something wrong?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 05, 2025, 12:05:43 PM
not sure, but i think it needs to be UserLabel123 insteed of Userlabel123

made a quick test here and it works
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 05, 2025, 12:58:39 PM
but are you using machscreen?
I tried to insert the text but it doesn't work for me, it takes the instruction as text
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 05, 2025, 01:04:11 PM
i am using MachScreen

https://kd-dietz.com/pages/eng/machscreen/description.html#

Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 05, 2025, 01:12:19 PM
made a quick test, it is for sure UserLabel needs to have a capital letter  -> L
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 06, 2025, 08:55:35 AM
Hi TPS, now it works, I was wrong, I copied and pasted on the line in machscreen the wording UserLabel123. And doing so it did not take it as a command. Rewriting it with the keyboard now it works.
Thanks a lot for the help.
I wanted to ask you since you suggested adding it to Macropump, since it cycles continuously, is there a risk of going to weigh down the system?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 06, 2025, 08:59:26 AM
i do not think that this one line of code in macropump will slow down anything.
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 06, 2025, 12:20:40 PM
thank you so much for your help.
Do you know if there is a way to block the manual insertion of the tool number on the panel? I would like the DRO tool of the mach3 panel not to be able to be changed manually...
Should I open another post or can we talk about it here?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 06, 2025, 01:12:49 PM
just put a image button transp. (without image) over the to of the tool DRO.

then select the image button again and the shown list will come up.
normaly the image button is the last in the list,
now click (left mousebutton) and hold mousebutton then move (with mouse)
the image button line up to be before the line with the DRO entry.
now it will be "in front" of the tool DRO and it can not be changed manualy.
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 03:21:15 AM
It works great, except that every time I open machscreen a window opens telling me that the image file is not found... is this correct? to set the transparent button when it makes me select the file inside the Mach3 folder since I can't leave everything blank I put .jpg... is this correct?
The prompt window is quite annoying :-)
And how do I make the button not execute any command when pressed?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 07, 2025, 03:29:51 AM
that is how i configured my "test" button
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 03:31:40 AM
ok this is to prevent the button from executing any commands...
because I was about to ask you how to make it not execute any command
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 03:34:12 AM
I can't write None in the Path box... when I click it it sends me to search for the image file to insert
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 07, 2025, 03:42:01 AM
if you insert a fresh one, there should be none as default
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 03:44:36 AM
when I insert it new it tells me that before inserting the button I have to point to the image file by opening the search window...
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 07, 2025, 03:44:55 AM
after insetring a "fresh" one just type 34 to standard code then select Standard Code -> Run basic script adjust position and size by mouse , done.
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 07, 2025, 03:48:17 AM
in the MachScreen Properties input mask under Control, i select Image button transp, then i use
the Add button and click into the screen to place it, i get nothing asked
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 03:53:23 AM
you are right, I was wrong because I inserted a normal image button and not a transparent image button. Thanks a lot for the help
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 04:14:54 AM
I share the code to make the write label command run only once in macropump
Code: [Select]
If GetUserLabel(123) = "" Then
    ' Leggi il numero utensile corrente
    Dim currentToolNumber As Integer
    currentToolNumber = GetDRO(24)
   
    ' Esegui il comando
    SetUserLabel(123, GetToolDesc(currentToolNumber))
   
    ' Aggiorna la variabile con il nuovo numero utensile
    lastToolNumber = currentToolNumber
End If
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: TPS on March 07, 2025, 04:17:26 AM
I share the code to make the write label command run only once in macropump
Code: [Select]
If GetUserLabel(123) = "" Then
    ' Leggi il numero utensile corrente
    Dim currentToolNumber As Integer
    currentToolNumber = GetDRO(24)
   
    ' Esegui il comando
    SetUserLabel(123, GetToolDesc(currentToolNumber))
   
    ' Aggiorna la variabile con il nuovo numero utensile
    lastToolNumber = currentToolNumber
End If

but now it will not be updated if you change for example from tool1 to tool2?
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 04:19:30 AM
and also the code that must always be inserted in macropump which both writes the label only once and changes the text of the label when the tool number changes when changing from the panel
Code: [Select]
' CODICE PRECEDENTE


' Definisci una variabile per memorizzare l'ultimo numero utensile (usa DRO 2005 come variabile persistente)
Dim lastToolNumber As Integer
lastToolNumber = GetoemDRO(1225) ' Leggi il valore persistente da DRO 1225

' Definisci una variabile per memorizzare il numero utensile corrente
Dim currentToolNumber As Integer

' Controllo del numero utensile all'inizio (solo se GetUserLabel(123) è vuoto)
If GetUserLabel(123) = "" Then
    ' Leggi il numero utensile corrente
    currentToolNumber = GetDRO(24)
   
    ' Esegui il comando
    SetUserLabel(123, GetToolDesc(currentToolNumber))
   
    ' Aggiorna la variabile persistente con il nuovo numero utensile
    SetDRO(1225, currentToolNumber)
    lastToolNumber = currentToolNumber
End If

' Controllo se il numero utensile è cambiato (solo se necessario)
currentToolNumber = GetDRO(24) ' Leggi il valore corrente
If currentToolNumber <> lastToolNumber Then
    ' Esegui il comando solo se il numero utensile è cambiato
    SetUserLabel(123, GetToolDesc(currentToolNumber))
   
    ' Aggiorna la variabile persistente con il nuovo numero utensile
    lastToolNumber = currentToolNumber
End If

' RESTO DEL CODICE
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 04:22:29 AM
yes exactly I will use the first one because in my case the tool number cannot be changed from the panel using the transparent image button, but can only be changed from the M6 ​​tool changer.
obviously I have the label update done in the m6Start script
Title: Re: LABEL WITH TOOL DESCRIPTION
Post by: Giuno85 on March 07, 2025, 04:23:16 AM
anyway I also shared the code to be able to change the label by manually changing the number from the panel