Oh no, not AI again?
Oh yes. Although ChatGPT got a whole load of exposure and caused a whole load of excitement last year, AI is a bit more useful than just a means of getting your homework done for you.
I've struggled to get Andy Pugh's macros to run on my LinuxCNC lathe. There's a "sim" (aka dummy demo) that implements the gmoccapy GUI with Andy's macros but to go from there to a functioning machine is a bit of a step. To get it running, you need to get all these elements set up and working correctly:
- .INI file. Contains file paths, machine parameters etc for your specific machine, including specifying the other config files.
- .HAL file. Provides the virtual wiring that connects the myriad external inputs and outputs, along with the RTOS-driven stepgen etc software elements that make things happen. My machine has closed loop positional control of the X and Z axes, using glass linear encoders, as well as a wireless pendant (WMPG).
- .UI file used by the Glade user interface. The "gmoccapy" lathe GUI is programmed in Glade by means of this .UI file.
- Various tool tables, macros etc.
- ...and of course, Andy's macros themselves.
Andreas Speiss:
Dave's Garage:
So, lets give this a go:
- Define the Subroutine Path
In the[RS274NGC]section, point to where the macro.ngcfiles are stored.If you keep them in your config folder, useSUBROUTINE_PATH = .. - Embed the Macro Tab
In the[DISPLAY]section, add the command to load the macro interface as a side tab.- lathehandler.py and lathemacro.ui must be in your configuration folder.
- notouch=1: Add this flag to the command if you want to use a physical keyboard for entry.
- norun=1: Use this to hide the on-screen "Run" button if you prefer using a physical Cycle Start button.
- Gmoccapy Specific Macro Buttons (Optional)
If you want quick-access buttons in the Gmoccapy MDI list, add a[MACROS]section.Gmoccapy supports up to 16 macros in this list.
lathehandler.py(Python logic)lathemacro.ui(GladeVCP interface)- All associated
.ngcsubroutine files (e.g.,facing.ngc,turning.ngc).
.ui or .py files. sim/gmoccapy/lathe_configs/lathe_macros.ini. - Open your terminal.
- Type
linuxcncto open the configuration selector. - Navigate to Sample Configurations > sim > gmoccapy > lathe_configs.
- Select lathe_macros.ini and click OK.
- Version Issues: This demo is verified to work in LinuxCNC 2.8. If you are on 2.9 or later, there is a known issue where the interface may fail to load due to Python 3 / GTK3 compatibility changes.
- Missing Images: In newer versions, the graphical background (SVG) may not render correctly unless you update the
lathehandler.pyscript. - Missing Files: If you are building a custom config from scratch, the required simulation files are located in the
macrosfolder within the GMOCCAPY sim folder.
EMBED_TAB_COMMAND line in your machine's INI file and potentially edit the lathemacro.ui file. [DISPLAY] section in your configuration's .ini file and change the EMBED_TAB_COMMAND line. The option that hides the button is norun=1. To make the button appear and be functional, you need to remove this option or explicitly set it to norun=0. - Original (Button Hidden):The
norun=1may be implied or explicitly present in the command line options. If present, remove it. - Modified (Button Visible):
Ensure the command does not containnorun=1. TheGitHub documentationfor the macros suggests the following syntax to explicitly keep it visible:The-U norun=0parameter ensures the action button remains visible.
lathemacro.ui file directly using a text editor. - Open the
lathemacro.uifile in a text editor. - Search for the string related to the "Action" or "Play" button.
- Ensure the visibility attribute for the button is set to
True(or similar, depending on the GTK version used). The buttons are still in the file and can be made visible this way.
lathemacro.ui, the "Play" buttons are intentionally hidden (or "greyed out") to encourage the use of physical cycle-start buttons. You can restore them by editing the .ui file with a text editor. lathemacro.ui- Search for "Action" and "Visible": Open the
.uifile and search for the stringActionto find the button definitions for each cycle (facing, turning, etc.). - Change Visibility Attributes: Look for the
<property name="visible">tag associated with these buttons. In newer versions, this property may be set toFalseor the entire button widget may be commented out. Change it to: - Identify Specific Widgets: While there are many "action" instances, look for the ones nested inside the
tabs1notebook. Each cycle has its own action button named after the tab (e.g.,Facing.action,Turning.action).
EMBED_TAB_COMMAND contains -U norun=1, the buttons will remain hidden regardless of the UI file settings. Ensure it is set as follows: lathemacro.ui, "Play" buttons (referred to as Action buttons) are replicated for each tab and are intentionally set to be invisible by default. To make them visible, users must edit lathemacro.ui to change the <property name="visible"> tag from False to True for each relevant Action object and potentially ensure the parent EventBox container is also visible. Additionally, the INI file must use -U norun=0 in the EMBED_TAB_COMMAND. Read more about Lathe Macros at the LinuxCNC Forum. lathemacro.ui file on GitHub, the "Play" buttons (Action buttons) are duplicated across different tabs (Facing, Turning, etc.) and are set to invisible by default. .action in a text editor. <property name="visible">False</property> to True:- Facing Action Button: Search for
Facing.action. The visibility property is typically located around Line 1770. - Turning Action Button: Search for
Turning.action. The visibility property is typically located around Line 3330. - Boring Action Button: Search for
Boring.action. The visibility property is typically located around Line 4890. - Threading Action Button: Search for
Threading.action. The visibility property is typically located around Line 7240.
.ui file, the buttons will remain hidden if your INI file is configured with the norun=1 flag. You must update your EMBED_TAB_COMMAND in the [DISPLAY] section: - Change this:
-U norun=1(or if it is missing) - To this:
-U norun=0
GtkOverlay system and manual XML positioning that Glade can break. Stick to a plain text editor like Gedit or Mousepad. sed) that will automatically flip all these "False" visibility tags to "True" for you.ngc (G-code) files or the parameter file. This often happens because the macro files are not in the expected search path. - Move Macro Files: Place all LatheMacro files (
lathemacro.ui,lathehandler.py, and all.ngcfiles) directly into your main machine configuration folder (e.g.,~/linuxcnc/configs/your_machine/) rather than a subfolder. - Update SUBROUTINE_PATH: Ensure your INI file includes the current directory in the search path so it can find the macro subroutines.
- In the
[RS274NGC]section of your.inifile, add or update:SUBROUTINE_PATH = .
(The dot indicates the current config folder).
- In the
- Check for Parameter File: Verify that your INI has a valid parameter file entry, as missing this can trigger "File not open" errors during macro execution:
[RS274NGC] PARAMETER_FILE = linuxcnc.var
- Confirm Machine State: The "Play" button in Gmoccapy will remain greyed out—even if visibility is set to True—if the machine is not Homed or if it is not currently in MDI mode.
If you still need to force the button's visibility in the XML:
SUBROUTINE_PATH = . line in the [RS274NGC] section? SUBROUTINE_PATH = . is already there and the file is fixed but you're getting "File not open," it means LinuxCNC can't find the .ngc files associated with the buttons. The "Play" button stays greyed out because the underlying G-code routine it's trying to "play" is missing or unreadable.lathemacro.ui is just the "skin." The logic lives in the .ngc files. You must copy all files ending in .ngc from the LatheMacros GitHub into your configuration folder.- Run this to check if they are there:If you don't see
facing.ngc,taper.ngc, etc., the button will never enable.
[DISPLAY] section:- A Macro is selected: You must click one of the side icons (like Facing or Tapering) first.
- Values are entered: If the fields are empty or contain invalid data, the "Play" button remains disabled to prevent a crash.
- Homed: You must home all axes.
.ngc files or ensuring that LinuxCNC itself is correctly installed and configured for their specific hardware.So, not a bad experience. Gemini actually went away and found Andy's Github site, opened the files and also worked out how they worked. And how to modify them to reinstate the hidden play button.
We'll call that a win.
No comments:
Post a Comment