一. FreeCAD的二次开发
freecad作为一款开源的三维软件,开发相当简便,使用python开发也更为简单。
二.环境配置
我是使用pycharm直接编辑新建的工作台文件夹,freecad自带的python2.7作为编译环境。
三. 主要文件
在mod文件夹下的工作台主要文件有
init.py 表示执行开始,一般没有实际内容,可以为空,但必须要有;
InitGui.py 工作台的ui内容;
然后就是其他的command文件;
四. InitGui.py的内容
# -*- coding: utf-8 -*-
# _TEMPLATEPY_ gui init module
# (c) 2001 Juergen Riegel
# License LGPL
# 继承workbench类,
class _TEMPLATEPY_Workbench ( Workbench ):#类名便是python控制台里的名字
"_TEMPLATEPY_ workbench object"
#加载工作台图标
Icon = FreeCAD.getHomePath() + "Mod/_TEMPLATEPY_/Resources/icons/_TEMPLATEPY_Workbench.svg"
MenuText = "WeiGan"#
ToolTip = "WeiGan workbench"
def Initialize(self):
# load the module
import _