3d打印利器FreeCAD入门教程之一----基础操作篇

FreeCAD是什么

FreeCAD是一种通用的3D CAD建模软件,来自法国Matra Datavision公司,是完全开源(GPL的LGPL许可证)易于学习和掌握的常用3d打印建模的工具。需要该软件可以自行从这里进行下载并安装使用,本文写作时,0.18版本即将发布,本文所描述的操作都是基于0.17版本的.

概要介绍

FreeCAD接口背后的主要概念是将它分成工作台(workbench)。工作台是适用于特定任务的工具集合,例如使用网格或绘图2D对象或约束草图。您可以使用工作台选择器切换当前的工作台。3d模型制作过程中,经常使用到的是零件设计工作台(Part Design)和零件工作台(Part)。见下图可供选择的workbench列表:
工作台-workbench
您将在FreeCAD中开始使用的工作台取决于您需要做的工作类型,比如:

  • 如果要使用机械模型,或者更常用的任何小型对象,则可能需要尝试零件设计(Part Design)工作台。
  • 如果在2D中工作,如果需要约束,则切换到草图工作台(drft)或素描(skecher)工作台
  • 如果想做BIM,则启动建筑工作台。如果您正在使用船舶设计,那么您将会有一个特殊的船舶工作台
  • 如果来自OpenSCAD世界,请尝试OpenSCAD 工作台。

您可以随时切换工作台,还可以通过自定义您最喜欢的工作台来添加其他工作台的工具。甚至可以通过’Tools-AddOn Manager’菜单来添加你喜欢的插件,比如说像螺丝钉螺纹的工作台就是通过插件的方式来添加的.

特别提一点,FreeCAD对中国用户还是比较友好的,提供了菜单的汉化,觉得英文菜单不舒服的同学,可以自行通过’Edit-Preference-General-Language-Change Language’来切换到中文.

在3D空间中导航

3d空间中导航的操作是你入门首先要掌握的技巧,可见下图;
鼠标操作

如果你想用触摸板及手势来操作,FreeCAD也做了相应的响应,请见这里的详细说明

如果是键盘操作:

  • CTRL SHIFT + 三键同时按下是放大, CTRL - 同时按下是缩小
  • 键盘的上下左右方向的箭头会让3D对象发生位移
  • SHIFT + 左箭头或右箭头,会让3D对象逆时针或顺时针旋转90度方向
  • 数字键1 到 6,分别代表了6个不同的标准视角:上前右下背左

在零件设计工作台和素描工作台中工作

零件设计工作台专门用于构建复杂的对象,从简单的形状开始,添加或删除形状块(我们称之为“特性(feature)”),直到你得到你想要的对象。您在建模过程中应用的所有功能都存储在名为树视图的单独视图中,该视图还包含文档中的其他对象。您可以将PartDesign对象视为一系列操作,每个操作都应用于前一个操作的结果,形成一个大链。在树视图中,您可以看到最终的对象,但可以展开它并检索所有先前的状态,并更改任何参数,这些参数会自动更新到最终对象。
树视图

零件设计(Part Design)工作台大量使用另一个工作台–素描(Skecher)工作台。素描器允许您绘制2D形状,通过将约束应用于 2D 形状来定义,如果你发现你的线条不能动弹的时候,你要想一想是不是要删除多余的约束。例如,您可以绘制一个矩形,并通过将长度约束(Constraints)应用于其中一边来设置边的大小,那么这条边不能再调整大小了(除非修改了约束)。
树视图

使用素描绘制器制作的2D形状在零件设计工作台中使用很多,例如创建3D立方体,或者绘制对象面上的区域,然后将其从主体空心化。这是一个典型的零件设计工作流程:

1.创建一个新的素描
2.绘制一个封闭的形状(确保所有点都被连接起来)
3.关闭素描
4.使用拉伸工具(工具栏上方的Pad a selected skech)将素描展开成3D立体
5.选择固体的一个面
6.创建一个第二个素描(这一次将在所选的面上绘制)
7.画一个封闭的形状
8.关闭素描
9.从第二个素描,在第一个对象上挖去一个洞
这给你一个这样的对象:
第一个建模操作

在任何时候,您可以选择原始素描并进行修改,或更改垫或挤压操作的缩放参数,这将更新最终对象。

专题扩展
关于FreeCAD的一些常见建模的概念及方式的主题,点击此处获取更多信息,敬请关注.

声明:文章属个人原创,个博地址见:
http://tech.limuqiao.com/archives/20.html

友情关注:2021年底即将推出我们墨飞鱼团队历时大半年研发的灵感写作平台,在墨飞鱼这里希望能帮助更多人找到阅读与写作的乐趣, 敬请收藏了解,12月底见哦~

Module developer’s guide to FreeCAD source code by Qingfeng Xia http://www.iesensor.com • 2015-09-18 version 0.1 for FreeCAD version 0.16-dev • 2016-09-18 version 0.2 for FreeCAD version 0.17-dev License of this book This ebook is licensed the same as FreeCAD document license CC-BY 3.0 http://creativecommons.org/licenses/by/3.0/Contents 1 FreeCAD overview and architecture 7 1.1 Introduction to FreeCAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2 Key features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3 Software architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3.1 Key software libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3.2 Mixed python and c++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.3.3 GPL code will not be included into installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4 How 3D model are renderred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4.1 Selection of 3D visualization libarary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.4.2 Discussion of 3D rendering library selection on FreeCAD Forum . . . . . . . . . . . . . . . . . . . . . 8 1.5 Roadmap of FreeCAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.5.1 Keep updated with main components: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.5.2 C++11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.5.3 Pyside 2 project for Qt 5.x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2 Organisation of FreeCAD source code 11 2.1 Build system for FreeCAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.1.1 Analysis of src/cMake/SMesh.cMake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 List of files and folders in FreeCAD source folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3 List of modules in FreeCAD Mod folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.4 Learning path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.5 Learning OpenInventor/Coin3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.5.1 OpenInventor in FreeCAD’s ViewProvider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.5.2 Important classes in OpenInventor/Coin3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.5.3 Window System integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.5.4 Pivy: Coin3D ’s Python wrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3 Base, App and Main module 19 3.1 List of header files in Base folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1.1 Frequently included headers files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.1.2 Correct way of using Sequencer in try-catch block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.1.3 String enconding utf8 and conversion into wchar_t QString . . . . . . . . . . . . . . . . . . . . . . . . 22 3.2 Type, BaseClass, PyObjectBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.2.1 Type system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.2.2 src/Base/BaseClass.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.2.3 src/Base/PyObjectBase.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2.4 src/Base/Persistence.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2.5 GeoFeature: Base class of all geometric document objects . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.3 Unit scheme for physial quantity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.3.1 src/Base/Unit.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.3.2 src/Base/Quantity.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.4 List of header files in App folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.5 Property framewrok . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.5.1 Naming of property and PropertyEditor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.5.2 src/App/PropertyStandard.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.3 PropertyEnumeration, see src/App/Enumeration.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.4 Geometry related property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.5 File related property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1
### 解析 Import Error 的常见原因 当遇到 `ImportError: cannot import name 'Generic'` 错误时,通常意味着尝试从模块中导入的对象不存在或无法访问。此问题可能由多种因素引起: - 版本不兼容:不同库之间的版本冲突可能导致此类错误。 - 安装缺失:目标库未正确安装或路径配置有误。 - 导入语句不当:可能存在循环依赖或其他语法层面的问题。 ### 针对 Generic 类型的具体解决方案 对于特定于 `Generic` 的情况,考虑到 Python 中 `Generic` 是 typing 模块的一部分,在处理该类别的 ImportError 时可采取如下措施[^1]: #### 方法一:确认typing模块可用性 确保环境中已安装标准库中的 typing 模块,并且其版本支持所使用的特性。可以通过以下命令验证: ```bash python -c "from typing import Generic; print(Generic)" ``` 如果上述命令执行失败,则可能是由于 Python 或者相关扩展包的版本过低造成的。此时应考虑升级至更高版本的解释器以及对应的开发工具链。 #### 方法二:调整导入方式 有时直接通过顶层命名空间来获取所需组件会更稳定可靠。修改代码以采用这种做法可能会解决问题: ```python from collections.abc import Iterable # 如果是迭代器相关接口 from typing import TypeVar, Protocol # 对于协议和泛型定义 T = TypeVar('T') class MyContainer(Protocol[T]): ... ``` 注意这里并没有显式提到 `Generic` ,而是利用了更为基础的数据结构抽象基类或是其他替代方案实现相同功能[^2]。 #### 方法三:排查环境变量设置 检查系统的 PYTHONPATH 和虚拟环境配置是否正常工作。任何异常都可能导致某些第三方软件包找不到必要的资源文件而引发类似的错误提示。建议清理并重建项目专属的工作区以便排除干扰项的影响。 #### 示例修正后的代码片段 假设原始代码试图这样引入 `Generic` : ```python from some_module import Generic # 可能导致 ImportError ``` 改为遵循官方文档推荐的方式后变为: ```python from typing import Generic # 正确的做法 ```
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值