how to create a link Button help me please !!
- Raen
- Offline
- New Member
- Posts: 13
- Thank you received: 0
<pyvcp>
<button>
<text>"program"</text>
</button>
</pyvcp>
program.xml --> placed in the same place as axis_mm.ini and on [display] have been add pyvcp = program.xml
this made button appear on software Emc2-Axis
1. how can i create link to call "holeicecircle.py" when i click the "program" button?
2. where should i put the "holeicecircle.py"?
3. please guide me step by step.......
Please Log in or Create an account to join the conversation.
- andypugh
- Away
- Moderator
- Posts: 23558
- Thank you received: 4858
You can make EMC2 run a G-Code command using the MDI_COMMAND option in the INI file.
You can create a "Custom M-code" from M101 to M199 that can be any executable file.
Firstly, as written the button does nothing at all, you probably need:
<pyvcp>
<button>
<text>"program"</text>
<halpin>"program"</halpin>
</button>
</pyvcp>
In the INI file you need
1) In the [HAL] Section
HALUI = halui
2) Add a section [HALUI]
[HALUI]
MDI_COMMAND = M101
3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
#!bin/sh
Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file.
You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line:
net btn1 halui.mdi-command-00 <= pyvcp.program
Please Log in or Create an account to join the conversation.
- Raen
- Offline
- New Member
- Posts: 13
- Thank you received: 0
Code:
#!bin/sh
And then the commands you would use to start the python script from the command line.
Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file.
You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line:
Code:
net btn1 halui.mdi-command-00 <= pyvcp.program
^
^
i dont understand this step....anyway thx for helping me ^^
Please Log in or Create an account to join the conversation.
- andypugh
- Away
- Moderator
- Posts: 23558
- Thank you received: 4858
net btn1 halui.mdi-command-00 <= pyvcp.program
i dont understand this step.
You need to create a link between the button and EMC2. At the moment it is just a button, it doesn't do anything. This line makes a link between the button (pyvcp.program) and the MDI_COMMAND. It then calls that "signal" btn1, but you could call it anything you like.
It has to go in the postgui.hal file as until the GUI has loaded and created the pyvcp panel, there is no pyvcp.program pin to link. (You can change the name of the pin to anything you want as long as it matches the <halpin> tag in the pyvcp xml file.)
Please Log in or Create an account to join the conversation.
- Raen
- Offline
- New Member
- Posts: 13
- Thank you received: 0
3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
(how to create an M101 executeable file? .exe / .py / .xml ??)
(what is the PROGRAM_PREFIX directory?)
Code:
#!bin/sh
(where should i put this command?)
And then the commands you would use to start the python script from the command line. (python script? "my program.py" ?)
Alternatively you can probably start the M101 file with "#!/usr/bin/env python" and then paste in all the python from your existing file. (how to configure this step? >.<)
You then need to link the button you created to the MDI_COMMAND pin, so, in the postgui HAL file add this line: (where's the postgui HAl file ?)
Code:
net btn1 halui.mdi-command-00 <= pyvcp.program
sorry for many question....but i hope that you want to help me....>.<
Please Log in or Create an account to join the conversation.
- andypugh
- Away
- Moderator
- Posts: 23558
- Thank you received: 4858
I would probably use Gedit (the text editor). Just create a new file, and call it M101, and save it.3) Create an M101 executable file and put it in your PROGRAM_PREFIX directory. Right-click it to make it executable. it should start with
(how to create an M101 executeable file? .exe / .py / .xml ??)
It is the directory where EMC2 looks for files. PROGRAM_PREFIX is a setting in the INI file which defines where it is.(what is the PROGRAM_PREFIX directory?)
In the text file you created above. Setting the file to be executable (right-click or use chmod) tells Linux that the file is a program. the <hash><exclamation><space> sequence tells Linux that the rest of the first line is the path to the interpreter that will execute the file, in this case the command shell.
#! bin/sh
(where should i put this command?)
Please Log in or Create an account to join the conversation.
- Raen
- Offline
- New Member
- Posts: 13
- Thank you received: 0
1. my xml file is int.xml --> i put this file in same place with axis_mm.ini file
<pyvcp>
<button>
<text>"program"</text>
<halpin>"program"</halpin>
</button>
</pyvcp>
2.axis_mm.ini [DISPLAY] section
pyvcp = int.xml
[HAL] section
HALUI = halui
then i add
[HALUI]
MDI_COMMAND = M101
3. i put a M101 file into NC_files
right click / properties / permissions tab / check a allow executing file as program
#!bin/sh already added at M101 file
4.i have create a intpostgui.hal and i put that file with the same place with my int.xml
intpostgui.hal file :
net btn1 halui.mdi-command-00 <= pyvcp.program
5. i confuse to place my "program.py" file....where should i put that file ?
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
- Posts: 7330
- Thank you received: 1177
Step 4 looks fine, not sure what your asking on step 5.
John
Please Log in or Create an account to join the conversation.
- Raen
- Offline
- New Member
- Posts: 13
- Thank you received: 0
i already done till step 3 but i still cant execute my "program.py" file from clicking my button named "program"
step 5 mean, is there any specific place for my "program.py" file to be placed?
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
- Posts: 7330
- Thank you received: 1177
John
Please Log in or Create an account to join the conversation.