QtPlasmaC – Magic Comments not creating materials from G-code
- MTTI
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 6
27 Nov 2025 11:34 - 27 Nov 2025 11:42 #339316
by MTTI
QtPlasmaC – Magic Comments not creating materials from G-code was created by MTTI
Hi everyone,I’m trying to use the Magic Comments in QtPlasmaC to automatically create/select materials from my G-code.
Example:
Result:
- QtPlasmaC shows an error like “invalid parameter in magic comment”
- The material is not created automatically
Material management in the GUI works normally
My goal is to automatically load correct cut settings (pierce height, cut height, feed rate, etc.) from the G-code generated in my CAM software.
Questions:
- Any specific setting to enable this feature in the INI / QtPlasmaC preferences?
- Could someone share a working example G-code header with material Magic Comments?
Thanks a lot in advance for your help!
Example:
(o=2, nu=2, na=5mm Mild Steel 40A, ph=3.1, pd=0.1, ch=0.75, fr=3000, kw=1.0)Result:
- QtPlasmaC shows an error like “invalid parameter in magic comment”
- The material is not created automatically
Material management in the GUI works normally
My goal is to automatically load correct cut settings (pierce height, cut height, feed rate, etc.) from the G-code generated in my CAM software.
Questions:
- Any specific setting to enable this feature in the INI / QtPlasmaC preferences?
- Could someone share a working example G-code header with material Magic Comments?
Thanks a lot in advance for your help!
Attachments:
Last edit: 27 Nov 2025 11:42 by MTTI.
Please Log in or Create an account to join the conversation.
- snowgoer540
-
- Away
- Moderator
-
Less
More
- Posts: 2503
- Thank you received: 843
27 Nov 2025 16:22 #339332
by snowgoer540
Replied by snowgoer540 on topic QtPlasmaC – Magic Comments not creating materials from G-code
Can you post your actual gcode file?
What version of qtplasmac are you running? It’s in the header of the window.
There is a temporary example file for
both metric and imperial in the nc_files\plasmac folder… here:
github.com/LinuxCNC/linuxcnc/blob/master...porary_materials.ngc
What version of qtplasmac are you running? It’s in the header of the window.
There is a temporary example file for
both metric and imperial in the nc_files\plasmac folder… here:
github.com/LinuxCNC/linuxcnc/blob/master...porary_materials.ngc
Please Log in or Create an account to join the conversation.
- MTTI
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 6
27 Nov 2025 18:11 #339337
by MTTI
Replied by MTTI on topic QtPlasmaC – Magic Comments not creating materials from G-code
Hi
This morning I was running v2.9-238.315 and later tested with v2.10-009.072. The issue was present on both versions.
I continued testing and the problem only occurs with o=1 and o=2 magic comments.
o=0 was always working correctly and did not cause any issue.
With o=1 and o=2, the material was written to the *_material.cfg* file, but QtPlasmaC showed a parameter error and did not update the material list. A restart of QtPlasmaC was required for the new material to appear.
I found the cause inside the function rewrite_material_file() in qtplasmac_gcode.
The code checks material_reload like this:But on my installation, this command returns:Since TRUE cannot be converted to int(), a ValueError exception is raised.
This stops the reload process, which leads to the UI not updating and to the misleading “parameter missing” message.
I applied a workaround that accepts both 0/1 and TRUE/FALSE strings:
After this fix:
* o=1 and o=2 now correctly create or update materials
* the UI refreshes immediately
* no more incorrect popup message
* no restart of QtPlasmaC required
* o=0 continues to work as before
I also added a local improvement: after a new material is created, it is automatically selected as the current active material.
If needed, I can provide a clean patch and test G-code examples.
I am also available to run additional tests if required.
I have attached to this post the NGC file I have been using since this morning.
The temporary example file was not working either, except when using o=0
Thanks
This morning I was running v2.9-238.315 and later tested with v2.10-009.072. The issue was present on both versions.
I continued testing and the problem only occurs with o=1 and o=2 magic comments.
o=0 was always working correctly and did not cause any issue.
With o=1 and o=2, the material was written to the *_material.cfg* file, but QtPlasmaC showed a parameter error and did not update the material list. A restart of QtPlasmaC was required for the new material to appear.
I found the cause inside the function rewrite_material_file() in qtplasmac_gcode.
The code checks material_reload like this:
response = RUN(['halcmd', 'getp', self.matReloadPin], capture_output=True)
if not int(response.stdout.decode()):
breakhalcmd getp qtplasmac.material_reload = TRUEThis stops the reload process, which leads to the UI not updating and to the misleading “parameter missing” message.
I applied a workaround that accepts both 0/1 and TRUE/FALSE strings:
raw = response.stdout.decode().strip().upper()
if raw in ['0', 'FALSE']:
break
else:
continueAfter this fix:
* o=1 and o=2 now correctly create or update materials
* the UI refreshes immediately
* no more incorrect popup message
* no restart of QtPlasmaC required
* o=0 continues to work as before
I also added a local improvement: after a new material is created, it is automatically selected as the current active material.
If needed, I can provide a clean patch and test G-code examples.
I am also available to run additional tests if required.
I have attached to this post the NGC file I have been using since this morning.
The temporary example file was not working either, except when using o=0
Thanks
Please Log in or Create an account to join the conversation.
Moderators: snowgoer540
Time to create page: 0.060 seconds