Help: Creating a button in Axis GUI for loading a specific G-Code file.

More
04 Mar 2024 10:05 #295120 by Aravind
ISSUE: Help for creating a button in axis gui for loading a specific G-Code file 

Hi,
I am trying to add a custom button in linuxcnc axis gui for loading a particular G-Code file. Well I need to operate this button using classicladder plc where this button will get activated when certain physical buttons are turned on. 

I could add a custom button in axis gui after referring the section "13.12. Add Button to manual frame" in the AXIS GUI document : linuxcnc.org/docs/2.8/html/gui/axis.html...d_a_goto_home_button

But I couldn't find how to use that button to load a particular g-code file.
And I am not able to locate that button address in hal configuration window for netting with classicladder pins.

Kindly help me to deal with this.

Hope to get response. 

-Aravind

Please Log in or Create an account to join the conversation.

More
04 Mar 2024 13:34 #295134 by Aciera
Yes
1. add this to the [RS274NGC] section of your ini file
USER_M_PATH = ./mcodes
2. add this to the [HALUI] section of your ini file
MDI_COMMAND = M127
3. create a folder 'mcodes' in your config folder and create a file 'M127' in this folder.
4. mark the file 'M127' as executable
5. copy this into the file 'M127' and save:
#!/bin/bash
axis-remote /home/user/linuxcnc/configs/sim/axis/nc_files/3D_Chips.ngc &
Note: this is the path/file you would need to adjust to load your specific file, here we load '3D_Chips.ngc' as an example '/home/user/linuxcnc/configs/sim/axis/nc_files/3D_Chips.ngc'
Also note that the '&' at the end is important, as otherwise the load command is blocked because the 'M127' command is still running.

You can now connect the MDI-command to your GUI button in the postgui hal file.
The following user(s) said Thank You: meister, Unlogic, Aravind

Please Log in or Create an account to join the conversation.

More
05 Mar 2024 12:29 #295224 by andypugh
You can _probably_ do this in fewer steps using a GladeVCP or QtVCP panel, as they support Python handler files which could directly interface with axis remote (or use the Python interface)

These would probably be more actual work, and more code to write, but would involve fewer steps in the command chain.
The following user(s) said Thank You: Aravind

Please Log in or Create an account to join the conversation.

More
05 Mar 2024 15:16 #295235 by cakeslob
Do the thing the other guys suggested, but in plasmac2 (and cakeslobs "regularmac800") we have a button panel where you can add button that loads a gcode/python/bash/ file. I havent played with it at all yet, but i think the python code for the usercommand file is something like this
       commands.open_file_name(code['file'])


github.com/cakeslob/regularmac_800/blob/...gularmac_800.py#L945

linuxcnc.org/docs/2.8/html/plasma/plasma...#custom-user-buttons
The following user(s) said Thank You: Aravind

Please Log in or Create an account to join the conversation.

More
06 Mar 2024 03:42 - 06 Mar 2024 04:07 #295284 by phillc54
A quick and dirty way is to have a user_command file with something along the lines of:
root_window.tk.eval('button .pane.top.tabs.fmanual.mybutton -text {Open\nMy File} -command {open_file_name /home/phill/linuxcnc/nc_files/3D_Chips.ngc} -height 2')
root_window.tk.eval('grid .pane.top.tabs.fmanual.mybutton -column 1 -row 6 -columnspan 2 -padx 4 -sticky w')

linuxcnc.org/docs/2.8/html/gui/axis.html#_user_command_file
 
Edit: Oops, I missed the bit about activating it from a hal pin...

This adds a hal pin named axis.loader to load the file:
loader = False
myFile = '/home/phill/linuxcnc/nc_files/3D_Chips.ngc'
myButton = 'Open\nMy File'
root_window.tk.eval(f'button .pane.top.tabs.fmanual.mybutton -text {{{myButton}}} -command {{open_file_name {myFile}}} -height 2')
root_window.tk.eval('grid .pane.top.tabs.fmanual.mybutton -column 1 -row 6 -columnspan 2 -padx 4 -sticky w')

def user_hal_pins():
    comp.newpin('loader', hal.HAL_BIT, hal.HAL_IN)

def user_live_update():
    global loader
    if loader != comp['loader']:
        loader = comp['loader']
        if loader:
            commands.open_file_name(myFile)
Last edit: 06 Mar 2024 04:07 by phillc54.
The following user(s) said Thank You: Aravind

Please Log in or Create an account to join the conversation.

Time to create page: 0.173 seconds
Powered by Kunena Forum