发烧友中心
如果你想深入理解FreeCAD,这里就是你该来的地方。你能学到如何为你的需求定制FreeCAD。
这些页面还远没有成熟。如果你没找到你要找的信息,或者你在别的地方发现了有用的信息,而我们没有链接在这里,那为什么不自己添加进来?同时,请在论坛留下你的意见。
FreeCAD最秒的好处之一,就是它给你的灵活性。你不需要作任何编译,不需要接触源代码,就可以写脚本,就可以作扩展,可触范围极广。所有的脚本都用Python完成。它是一门强大而简洁的编程语言。有了简洁的Python脚本,你有权触及FreeCAD的任何部分。比如说,你可以:
- 创建和修改几何体:有没有这种情况?你需要的特殊对象,没有出现在FreeCAD的默认安装包里?你可以轻松创建一个新对象类型,既可以写脚本,也可以调配一个已有的类型。
- 创建定制的工具和命令:目前,FreeCAD已经有了很广泛的功能,但是给终端用户的工具和命令还不是很多。不过,你已经可以很容易地创建自己的工具包了。
- 修改界面:FreeCAD的用户界面还处于十分基础的阶段。但是如果你要有所扩展,工具都给你准备好了。比如说,你可以创建一个工具条,把你的工具都放进去;你也可以创建一个特殊面板,用来与你的工具互动,诸如此类。
- 修改场景表现:建立和计算几何体,在屏幕上显示那个几何体,这件事在FreeCAD里有不同的流程来处理。场景元素显示在屏幕上的方式,你对此有完全控制权。所以,你可以修改那个表现,与它交互,或者加入各种各样的定制行为和屏幕组件。举几个例子,信息、拖拽、锚定或者暂时实体。
定制FreeCAD
在FreeCAD里写脚本
通则
- 介绍Python - 在页面底端还有其他Python教程。
- FreeCAD脚本教程 - 概略看一下在FreeCAD中用Python写脚本。
- FreeCAD脚本基础 - 好吧,基本的东西……
- Gui命令 - 向GUI添加定制的命令。
- 在FreeCAD里使用混合单位。
模块
在FreeCAD中,功能性的东西被划分到各个模块,处理特定的数据类型和应用。FreeCAD有内建模块和扩展模块(插件)。插件模块一旦安装,它们就和内建模块一样方便触达。下面讲的是默认模块,FreeCAD的每一个安装包都包含了。
网格类工作
零件类工作
- 零件模块:开源CASCADE技术的工具和体系如何用在FreeCAD中。
- 拓扑数据脚本:怎样与零件模块交互。
- PythonOCC:怎样释放开源CASCADE的全部能量。
- 网格到零件:转换对象类型。
Accessing the Coin scenegraph
- The Coin/Inventor scenegraph: How the FreeCAD scene representation works
- Pivy: How to access and modify the scenegraph
Controlling the Qt interface
- PySide: How to access the interface, and modify its contents
- Using the FreeCAD GUI in another Qt application with PyQt
Working with parametric objects
- Scripted objects: How to make 100% Python-scripted objects in FreeCAD
- Drawing Module: Automating the 3D-to-2D process
Examples
- Code snippets : A collection of pieces of FreeCAD Python code, to serve as ingredients in your scripts...
- Line drawing function: How to build a simple tool to draw lines
- Dialog creation: How to construct dialogs with Qt designer, and use them in FreeCAD
- Embedding FreeCAD: How to import FreeCAD as a Python module in other applications
- The Draft Module adds basic 2d drawing functions to freecad. It is written entirely in Python, so it can be a good example if you want to write your own modules.
- FreeCAD vector math library : A couple of handy functions to manipulate FreeCAD vectors. This library is also included in the Draft module.
API Functions
The complete API documentation of FreeCAD is located at http://www.freecadweb.org/api/ . It contains both C++ and Python APIs, and is not totally well formatted yet, which can be confusing when looking for python-only code. An easier to browse version can be found here. Note that it can be incomplete, since it is updated manually. For more accurate information, browse the modules directly from FreeCAD's Python console.
Advanced modification
- Start up and Configuration: Startup and command line options
- Install on Windows: Using the windows installer
- Compiling FreeCAD on Windows and Compiling FreeCAD on Unix
- Branding: Simple modifications you can do to the source code to change some aspects of FreeCAD
- Extra python modules : Extend the FreeCAD python interpreter with these powerful modules!
Python tutorials
These are good generic tutorials, not specific to FreeCAD, that might interest you if you are totally new to python.
Python
- Official python tutorial - A very complete tutorial for discovering python
- Non-programmer tutorial for python - an excellent wikibook
- Python for newbies - one big tutorial covering all the basics
PySide - How to create and manage FreeCAD's Qt UI interface from python
- PySide tutorial : A platform-agnostic tutorial showing the usage of PySide with examples
- PySide/PyQt tutorial : A easy to read tutorial that covers PySide and PyQt with examples
- PySide documentation : from the Qt Project (the people who wrote it all)
- Using QtCreator in PySide : also from the Qt Project
- PySide reference : endless detail on the minutiae of PySide and Qt, a reliable reference source
- PySide code snippets : a searchable database of PySide code snippets
The following two references are PyQt specific (not PySide) but may offer some information of use:
- Basic PyQt tutorial : A simple and short linux-based tutorial that will explain how to work with PyQt and Qt Designer
- Programming Qt applications in python : A more in-depth tutorial covering all the process of working with qt and python.
Pivy - How to interact with FreeCAD's 3D scenes
- Basic Pivy tutorial : A very simple tutorial from the official Pivy site
- Introducing Pivy into studierstube : A document that is not really a tutorial, but that illustrates well how Pivy works
Community projects
On the Community portal, you can find other FreeCAD-based projects run by the FreeCAD users community. If you are starting a new FreeCAD project, be sure to list it there! We also have a page with things you can do if you would like to Help FreeCAD.