linuxcnc python 简单的图形界面

Simple EMC G-Code Generators Written in Python

1. Drilling Speeds-n-Feeds
2. Arc Buddy
3. Facing Software
4. Bolt Circle Array Software
5. Counterbore Software
6. Grill Drilling Software
7. Bezel Engraving Software
8. Text Engraving Software
9. Pycam - Drop Cutter Surfacing Software
10. Dxf2gcode - import a 2D DXF file and produce G-code
11. Rectangulare-Circulare Pocketing Generator
12. Grid Rectangular Circular SpiderNet G-code Generator
13. Other G Code Generators
14. Using Python scripts with Axis
15. Using Python scripts with Windows
16. Using Python scripts online
17. mGcodeGenerator
From the official Python web site http://python.org/ "Python is a dynamic object-oriented programming language that can be used for many kinds of software development." Python is powerful,open source, cross platform compatible and easy to learn and use. It has become one of the favorite languages of the EMC development group. A tutorial for Python can be found here http://docs.python.org/tutorial/

This page contains links to Python scrips that generate simple G-Codes for EMC. For me to fire up a high dollar CAD program and the use the POST processor to generate simple routines is a time waster. So I'm writing a series of Python programs to do this. If you did an EMC install with Ubuntu you are good to go you have all you need. Make sure you make the mods to your ini file so you can open these up from Axis and paste the generated code directly into Axis... as shown at the bottom of the page.

The programs will do Facing, Pockets, Slots, Drill Patterns etc. When they are all finished I'll package them all up into one.

1. Drilling Speeds-n-Feeds

This one helps you to calculate the speeds and feeds for drilling
upload:Drill00.png

upload:drill.py Version 0.1
Some interesting reading on chip loading upload:Chip%20Load%20on%20Drills.odt
2. Arc Buddy

This one takes the center of an arc, the diameter, the start and end angle and spits out the G-Code
The start point for the arc and the G2/3 code for the arc are generated.
There might be a couple of bugs left in the code. If you find one e-mail me and I'll fix it.
upload:Arc%20Buddy.odt A very short tutorial on Arc Buddy
upload:Arc%20Tutorial%202.odt A more advanced tutorial on making arcs.
upload:Arcbuddy12.png

upload:arcbuddy.py Version 1.1
This is a slightly different version of Arc Buddy that was modified by Sebastian Jardi Estadella for use in gEdit to insert the gcodes. The instructions for use with gEdit are in the comments section.

upload:arcbuddy-sje.py

3. Facing Software

The facing software is super simple. You input a few things and press a button and your code is saved to your NC directory ready to open in EMC2!

upload:face-134.py Version 1.3.4 Last Updated on Jan 6, 2010 License is GNU license.
for windows users download and rename face-134.py to face-134.pyw, download and install python2.4 [from Python.org]
upload:face-134.png
Features
Lead-in, lead-out value can now be changed - version 1.3.4
Now has a radio button to set the X0-Y0 (Home) position: Left-Rear or Left-Front - version 1.3.3b
To change the default, see the comments in the file
Now has a radio button for Inch/MM Version 1.3.2
Now accepts fractions in any field where this is appropriate. Version 1.3.1
One step file save after setting the NC File Directory Option.
Vertical Scroll Bar added to text box.
Added Spindle Speed setting that automaticly adds M2 and M5 if you specify a value
Can leave Depth of Cut, Spindle Speed and Stepover blank.
Added a menu!
NC File Directory is saved to an .ini file!
If you open in Axis you can directly save the g code to Axis!!!
Undocumented Features
Assumes that the top of the material is Z0 and nothing is above Z0
4. Bolt Circle Array Software

upload:boltcircle2.py
This program generates a circular array for canned drill cycles in a mill (ie 'bolt circle'). This program used face.py as a template, so it looks very similar. Some of the entry widgets have predefined values in them. Look carefully at these before pressing the 'Generate G-code' button (-Dan Falck).
5. Counterbore Software

upload:counterbore.py
Version 1.3.1
This software generates the G-code for counterbores for socket head cap screws.
If you have any comments just e mail me Big John T.
Features
Pick a SHCS from one of the three lists and it puts the standard diameter and depth in for you.
Minimum entrys needed are hole diameter/depth, tool diameter and location of the hole.
M2 end of file option if you have to generate several size holes only use it on the last hole.
Editing of X & Y list with mouse clicks on item. Maintains order if one is edited and put back.
Speedy entry using number key pad and the key pad enter key for locations.
Bugs
At this time there is a bug if you have a path that does not require a spiral... working on it
upload:Counterbore.png

6. Grill Drilling Software

Version 1.3 upload:grill-13.py
Version 1.2 upload:grill-12.py
This software peck drills a circular array of holes typically used as a speaker grill or
as ventilation holes in a chassis panel.
Features
Can drill circular, elliptical, rectangular or oval shaped arrays of holes
Usable as an axis filter program (see below)
Gcode can be copied to the clipboard for easy insertion into other gcode programs
upload:grill-13.png

7. Bezel Engraving Software

upload:bezel-11.py
Version 1.1
This software engraves a bezel like you would see on the front panel of a stereo around the volume control knobs.
Features
adjustable number of minor and major ticks
adjustable start and stop positions
center position is marked with a dot for later drilling operations
usable as an axis filter program (see below)
gcode can be copied to the clipboard for easy insertion into other gcode programs
use of variables for center point and Z values for easy code block reuse
upload:Bezel11.png

8. Text Engraving Software

upload:engrave-12.py Version 1.2
upload:cxf-fonts.tgz Old format cxf fonts
This software engraves a text string.
Features
uses Qcad font files (nice stroked font definitions)
NOTE: As of 12Sept2014 this version of engrave only knows how to parse Version 1 .cxf font files.
You can open the font file with a text editor and look at line 3 to see if the font file is compatible.
Also, if you see the font path highlighted in RED, you probably do not have a correct path to a .cxf font file.
You will need to obtain .cxf font files from the link above or use the ones from the qcad V2 package (Qcad V3 fonts do NOT parse properly)
supports flipped(about x axis) or mirrored(about y axis) text
mirrored text is useful for back cutting on Plexiglas panels
usable as an axis filter program (see below)
independent X and Y scaling so the look of a font can be modified
adjustable character and word spacing
string can be plotted at any arbitrary angle
gcode can be copied to the clipboard for easy insertion into other gcode programs
use of gcode variables for start point, scaling, rotation and Z values for easy code block reuse or tweaking
Version 1.2 adds variable for linear arc conversion precision
upload:engrave12-scrn.png

9. Pycam - Drop Cutter Surfacing Software

upload:pycam_screenshot.png

A GPL 3D CNC Toolpath Generation program written by Lode Leroy

http://pycam.wiki.sourceforge.net/
Requires python, pyopengl, and togl to run under linux
Download from here:
http://sourceforge.net/project/showfiles.php?group_id=237831
10. Dxf2gcode - import a 2D DXF file and produce G-code

upload:DXF%202%20G-Code,%20Version%200.1.png

Written by Christian Kohloeffel.

Url translated to English by Google:

http://64.233.179.104/translate_c?hl=en&langpair=de|en&u=http://www.christian-kohloeffel.homepage.t-online.de/dxf2gocde.html
Original URL: http://www.christian-kohloeffel.homepage.t-online.de/dxf2gocde.html

Download from here:

http://code.google.com/p/dxf2gcode/ old dead url(http://dxf2gcode.vegasoft.de/2008-07-27-dxf2gcode_v01_src.zip)
This program seems to work pretty well with DXF files from QCAD.

11. Rectangulare-Circulare Pocketing Generator

This is for Generating simple Pocket Style Toolpathes with Differnt depth/stepover
Version 1 does only support Zero Path but you can simply edit the final path to G41 new spiral depth mode (04 2011)
upload:pocket_V1.py
Screenshot :
upload:pocket_v1.png
Written by Sammel Lothar Germany
12. Grid Rectangular Circular SpiderNet? G-code Generator

This wars written to test the speed and the acurathy of a milling mashine,
  with the grid alot of moves are taken and you can see the accurate by,
  checking Zero Border on the grid if it not harming the outside Shape!
  Now all shapes and functions are includet Aug_2010!
upload:grid_v1.py
upload:grid_v1_0.png
upload:grid_shape.png
Written by Sammel Lothar Germany
13. Other G Code Generators

http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Cp1 CP1 is a conversational machining program written by Ray Henry and Matt Shaver with additional MOP's by Lawrence Glaister.
http://www.timeguy.com/cradek/truetype A TrueType? tracer with DXF and G-Code output
14. Using Python scripts with Axis

To download a file right click on it and select "Save link as"
Do the following...

Place the .py files in your nc directory so it is easy to find
Right click on the .py file in your file browser and select Properties. On the Permissions tab check Execute on the Owner line.
Add the following lines to the [FILTER] section of the Axis ini file
[FILTER]
PROGRAM_EXTENSION = .py Python Script
py = python
If you don't have a [FILTER] section just add it
Now use File Open in AXIS to open face.py and after you generate the g-code select Write to AXIS and Quit
15. Using Python scripts with Windows

Rename the file from .py to .pyw
Download and install the python program
16. Using Python scripts online

upload:online_python.png Here are some python generators that can be used from emc and online too. They are simple, but you can easily make new ones for yourself... using the hugomatic library, that abstracts the user interface. This is beta software, so please provide feedback. http://hugomatic.ca
17. mGcodeGenerator

It is a script for Blender. It can generate gcode ideal for emc^2 :) it export from mesh ( vertex / edge / edges (outlines) / objects ) to 2d, 2.5d and full 3d for (3axis mill).
LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited September 14, 2014 6:50 pm by LawrenceG (diff)
Search: Published under a Creative Commons License

### LinuxCNC GUI开发教程及自定义界面设计 在LinuxCNC中进行GUI开发,通常会结合Python语言和PyQt图形库来实现。以下是对相关内容的详细说明: #### 1. 开发环境与工具选择 LinuxCNC支持多种编程语言和图形库用于界面开发,其中推荐使用Python结合PyQt[^1]。Python作为一种脚本语言,具有面向对象、公开免费、跨平台可移植等优点。PyQt是Python与Qt图形库的结合体,提供了丰富的模块、良好的跨平台支持以及信号与槽机制,非常适合用于开发复杂的用户界面。 #### 2. LinuxCNC代码结构概述 LinuxCNC的源码结构清晰地划分了各个功能模块,包括命令解释器、运动规划、任务控制器、轨迹规划、硬件抽象层等[^2]。这些模块为开发者提供了底层支持,使得上层GUI可以通过调用LinuxCNC提供的Python接口与任务控制器通信,并监视状态信息和错误信息。 #### 3. 自定义界面开发步骤 以下是基于Gmoccapy界面的自定义开发流程示例: - **启动Gmoccapy界面**:通过桌面左上角的应用程序菜单,选择《CNC》并启动LinuxCNC Contig Picker,勾选“Create desktop Shortcut”以创建快捷方式[^3]。 - **界面调整**:如果分辨率不足导致界面无法完全显示,可以将VMware设置为全屏模式,并将LinuxCNC窗口最大化。 - **紧急按钮与控制按钮**:单击紧急停止按钮(数字1),然后启动或暂停任务(数字2)。 - **刀具归零操作**:通过调节刀具归零按钮(数字3),可以实现刀具的全部归位或单独X轴、Y轴、Z轴归位。 - **界面元素扩展**:开发者可以根据需求修改现有按钮的功能或添加新的控件。 #### 4. PyQt结合LinuxCNC开发实例 以下是一个简单的PyQt代码示例,展示如何通过Python调用LinuxCNC接口实现基本的界面交互: ```python import sys from PyQt5.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget from PyQt5.QtCore import QObject, pyqtSignal class LinuxCNCInterface(QObject): status_updated = pyqtSignal(str) def __init__(self): super().__init__() self.status = "Idle" def start_task(self): print("Starting task...") self.status = "Running" self.status_updated.emit(self.status) def stop_task(self): print("Stopping task...") self.status = "Idle" self.status_updated.emit(self.status) class CNCControl(QWidget): def __init__(self): super().__init__() self.init_ui() def init_ui(self): layout = QVBoxLayout() self.start_button = QPushButton("Start") self.start_button.clicked.connect(self.on_start_clicked) layout.addWidget(self.start_button) self.stop_button = QPushButton("Stop") self.stop_button.clicked.connect(self.on_stop_clicked) layout.addWidget(self.stop_button) self.setLayout(layout) self.linuxcnc_interface = LinuxCNCInterface() self.linuxcnc_interface.status_updated.connect(self.on_status_updated) def on_start_clicked(self): self.linuxcnc_interface.start_task() def on_stop_clicked(self): self.linuxcnc_interface.stop_task() def on_status_updated(self, status): print(f"Status updated: {status}") if __name__ == "__main__": app = QApplication(sys.argv) window = CNCControl() window.show() sys.exit(app.exec_()) ``` 此代码展示了如何通过PyQt创建一个简单界面,包含启动和停止按钮,并通过信号与槽机制与LinuxCNC接口进行交互[^1]。 #### 5. 注意事项 - 确保开发环境已正确安装Python、PyQt以及LinuxCNC的相关依赖。 - 在设计界面时需充分考虑用户体验,合理布局控件并提供必要的反馈信息。 - 测试阶段应验证界面与底层功能的兼容性,确保所有交互逻辑正常运行。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值