calling python file

More
27 Oct 2024 14:20 #313300 by Abdulkareem
how to make an m code that runs a python script

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

More
27 Oct 2024 15:04 #313309 by Aciera
Replied by Aciera on topic calling python file
1. add this to the [RS274NGC] section of your ini file:
    USER_M_PATH = ./mcodes

2. save your python script as eg 'M123' (possible numering is 100...199) to the 'mcodes' folder in your machine config directory and mark the file as executable

3.'M123' in Gcode should now execute the script.
The following user(s) said Thank You: Abdulkareem

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

More
29 Oct 2024 09:15 #313418 by Abdulkareem
Replied by Abdulkareem on topic calling python file
I did as you said but i get an error of unknown m code
Attachments:

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

More
29 Oct 2024 09:16 #313419 by Abdulkareem
Replied by Abdulkareem on topic calling python file
do i need to add REMAP = M199 python = M199(the name of the script)

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

More
29 Oct 2024 09:50 - 29 Oct 2024 09:50 #313420 by Aciera
Replied by Aciera on topic calling python file

 I did as you said but i get an error of unknown m code

Possible causes:
- USER_M_PATH is incorrect (this is supposed to point to the directory that contains your 'M199' file not to the file itself )
- File name is incorrect (Do not add an extension eg .py)
- The file is not marked as executable

 do i need to add REMAP = M199 python = M199(the name of the script)


No, this is not a remap, it's a custom mcode (which lets you use any executable script)
Last edit: 29 Oct 2024 09:50 by Aciera.
The following user(s) said Thank You: Abdulkareem

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

More
29 Oct 2024 10:02 #313421 by Abdulkareem
Replied by Abdulkareem on topic calling python file
Thank you i solve the issue by removing the .py extension and adding it to the right directory

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

Time to create page: 0.096 seconds
Powered by Kunena Forum