Part Module/zh-cn: Difference between revisions
(Updating to match new version of source page) |
(Updating to match new version of source page) |
||
Line 136: | Line 136: | ||
* [[Image:Part_CheckGeometry.svg|32px]] [[Part CheckGeometry|Check geometry]]: Checks the geometry of selected objects for errors. |
* [[Image:Part_CheckGeometry.svg|32px]] [[Part CheckGeometry|Check geometry]]: Checks the geometry of selected objects for errors. |
||
=== |
=== Context menu items === |
||
*[[Std_SetAppearance|Appearance]]: determines appearance of the whole part (color transparency etc.). |
*[[Std_SetAppearance|Appearance]]: determines appearance of the whole part (color transparency etc.). |
||
Line 147: | Line 147: | ||
</div> |
</div> |
||
== |
== 脚本 == |
||
在OpenCascade术语中,我们会在几何图元(geometric primitive)与拓扑形状(topological shape)之间进行区分。一个几何图元可以是点、线、圆、平面等等,甚至还可以为类似于B-样条曲线或表面(surface)这样更为复杂的图元类型。而拓扑形状则可以是顶点、边、连线、面(face)、实体或其他形状所复合而成的对象。几何图元不能直接显示于3D场景中,却常用于构建拓扑形状的几何图形。例如,一条边可由线或部分圆来构建而成。 |
|||
<div class="mw-translate-fuzzy"> |
<div class="mw-translate-fuzzy"> |
||
{{Emphasis|参见:}} [[Part scripting|零件脚本]] |
|||
总而言之,几何图元都是“无形状”的基本构成单位,而拓扑形状则是基于前者所构建的实体对象。 |
|||
</div> |
</div> |
||
<div class="mw-translate-fuzzy"> |
<div class="mw-translate-fuzzy"> |
||
至于全部图元与形状的完整列表可参考 [http://www.opencascade.org/org/doc/ OCC文档] (或者: [http://opencascade.sourcearchive.com/documentation/6.3.0.dfsg.1-1/classes.html sourcearchive.com])以'''Geom_*'''搜索几何图元,以'''TopoDS_*'''搜索拓扑形状。在此,您可以阅读到两者间更多的不同点。请注意,官方的OCC文档并不存在于网络上(您必须下载一份存档文件),而且它主要为程序员而设,并非终端用户。但是,仍希望您能以此为起点来查找更为深入的信息。 |
|||
</div> |
|||
<blockquote style="color: slategray">''At a very high level, topology tells what pieces an object is made of, and the logical relationships between them. A shape is made of a certain set of faces. A face is bounded by a certain set of edges. Two faces are adjacent if they share a common edge.''</blockquote> |
|||
<blockquote style="color: slategray">''Topology alone does not tell you the size, curvature, or 3D locations of any of those pieces. However, each piece of topology does knows about it's underlying geometry. A face knows what surface it lies on. An edge knows what curve it lies on. The geometry knows about curvature and location in space.'' - [https://www.opencascade.com/content/geometry-and-topology Source]</blockquote> |
|||
<hr /> |
|||
<blockquote style="color: slategray">''Thus, Topology defines the relationship between simple geometric entities, which can be linked together to represent complex shapes.'' - [https://www.opencascade.com/doc/occt-7.0.0/overview/html/occt_user_guides__modeling_data.html Modeling Data User's Guide]</blockquote> |
|||
[[File:ClassTopoDS_Shape_inherit_graph.png]] |
|||
<div class="mw-translate-fuzzy"> |
|||
几何类型实际可分为两大关键组群:曲线(curve)与表面(surface)。您可利用曲线(线、圆……)来直接构建一个边,而采用表面(平面,圆柱体……)来构建一个面(face)。例如,几何图元中的线是无限长的,即它由一个基向量与一个方向向量定义而成,而线的拓扑形状表示却一定要以起点与终点来定义为有限长度。另外,一个立方体——一个实体——可用6个有限的平面来创建。 |
|||
</div> |
|||
<div class="mw-translate-fuzzy"> |
|||
当然,您也可以将一条边或一个面还原为其对应的几何图元。 |
|||
</div> |
|||
<div class="mw-translate-fuzzy"> |
|||
这样一来,利用区区几种形状您就可以构建出灰常复杂的零件。反之,您亦可以从一个更加复杂的形状中提取出构成它的所有子形状。 |
|||
</div> |
|||
Thus, out of shapes you can build very complex parts or, the other way round, extract all sub-shapes a more complex shape is made of. |
|||
[[File:Part_TopoShape_relationships.svg|600px]] |
|||
{{Caption|The {{incode|Part::TopoShape}} class is the geometrical object that is seen on screen. Essentially all workbenches use these [[Part_TopoShape|TopoShapes]] internally to build and display edges, faces, and solids.}} |
|||
== 脚本 == |
|||
{{Emphasis|参见:}} [[Part scripting|零件脚本]] |
|||
零件模块中主要使用的数据结构为OpenCascade中的 [http://en.wikipedia.org/wiki/Boundary_representation BRep]数据类型。几乎零件模块中的所有内容与对象类型都可在[[Python|Python]]脚本中使用。这其中包括几何图元,如线段与圆形(或弧), 以及整个TopoShapes范畴,如顶点、边、连线、面、实体与组合对象。对于其中的每一种对象而言,都存在若干创建方法,而对于TopoShapes中的特定对象而言,还支持一些如布尔并集/差集/交集等高级操作。以[[FreeCAD Scripting Basics|FreeCAD脚本基础]]页面所述的方式来浏览零件模块中的内容,即可获悉更多详情。 |
|||
The most basic object that can be created is a [[Part Feature|Part Feature]], which has a simple {{PropertyData|Placement}} property, and basic properties to define its color and appearance. |
|||
Another simple object used in 2D geometrical objects is [[Part Part2DObject|Part Part2DObject]], which is the base of [[Sketcher_SketchObject|Sketcher SketchObject]] ([[Sketcher Workbench|Sketcher]]), and most [[Draft Workbench|Draft elements]]. |
|||
=== Test script === |
|||
Test the creation of [[Part_Primitives|Part Primitives]] with a script. {{Version|0.19}} |
|||
{{Code|code= |
|||
import parttests.part_test_objects as pto |
|||
pto.create_test_file("example_file") |
|||
}} |
|||
This script is located in the installation directory of the program, and can be examined to see how the basic primitives are built. |
|||
{{Code|code= |
|||
$INSTALL_DIR/Mod/Part/parttests/part_test_objects.py |
|||
}} |
|||
=== 示例 === |
|||
为了创建一条线条元素,可以切换至Python控制台并录入: |
|||
{{Code|code= |
|||
import Part,PartGui |
|||
doc=App.newDocument() |
|||
l=Part.LineSegment() |
|||
l.StartPoint=(0.0,0.0,0.0) |
|||
l.EndPoint=(1.0,1.0,1.0) |
|||
doc.addObject("Part::Feature","Line").Shape=l.toShape() |
|||
doc.recompute() |
|||
}} |
|||
让我们来逐步分析上述python示例: |
|||
{{Code|code= |
|||
import Part,PartGui |
|||
doc=App.newDocument() |
|||
}} |
|||
加载零件模块并创建一个新文档 |
|||
{{Code|code= |
|||
l=Part.LineSegment() |
|||
l.StartPoint=(0.0,0.0,0.0) |
|||
l.EndPoint=(1.0,1.0,1.0) |
|||
}} |
|||
线条其实就是线段,因为它具有起点和终点。 |
|||
{{Code|code= |
|||
doc.addObject("Part::Feature","Line").Shape=l.toShape() |
|||
}} |
|||
这行代码为文档添加了一个零件对象类型,并为此对象的'Shape'属性设置为以线段进行形状表示。在此,关键是要理解我们通过几何图元(Part.LineSegment)创建了一个TopoShape(利用toShape()方法)。只有几何图形才能添加至文档中。在FreeCAD中,几何图元常用作几何图形的“基本组成结构”。 |
|||
{{Code|code= |
|||
doc.recompute() |
|||
}} |
|||
此句更新了文档。这为新零件对象的可视化表示做好了准备工作。 |
|||
请注意,我们可以直接通过在构造函数中指定起点与终点来创建一条线段,例如 Part.LineSegment(point1,point2),或者正如我们此前的做法,在创建一条默认线段后再调整其属性。 |
|||
A Line can be created also using: |
|||
{{Code|code= |
|||
import FreeCAD |
|||
import Part |
|||
DOC = FreeCAD.newDocument() |
|||
def mycreateLine(pt1, pt2, objName): |
|||
obj = DOC.addObject("Part::Line", objName) |
|||
obj.X1 = pt1[0] |
|||
obj.Y1 = pt1[2] |
|||
obj.Z1 = pt1[2] |
|||
obj.X2 = pt2[0] |
|||
obj.Y2 = pt2[1] |
|||
obj.Z2 = pt2[2] |
|||
DOC.recompute() |
|||
return obj |
|||
line = mycreateLine((0,0,0), (0,10,0), "LineName") |
|||
}} |
|||
以相似的方式来创建一个圆形: |
|||
{{Code|code= |
|||
import Part |
|||
doc = App.activeDocument() |
|||
c = Part.Circle() |
|||
c.Radius=10.0 |
|||
f = doc.addObject("Part::Feature", "Circle") |
|||
f.Shape = c.toShape() |
|||
doc.recompute() |
|||
}} |
|||
or using: |
|||
{{Code|code= |
|||
import FreeCAD |
|||
import Part |
|||
DOC = FreeCAD.newDocument() |
|||
def mycreateCircle(rad, objName): |
|||
obj = DOC.addObject("Part::Circle", objName) |
|||
obj.Radius = rad |
|||
DOC.recompute() |
|||
return obj |
|||
circle = mycreateCircle(5.0, "CircleName") |
|||
}} |
|||
请再次注意,这段代码利用圆形(几何图元)构建了一个几何形状。之后,我们依然能通过下列方式访问造型几何体: |
|||
{{Code|code= |
|||
s = f.Shape |
|||
e = s.Edges[0] |
|||
c = e.Curve |
|||
}} |
|||
在此,我们获取对象f的几何形状,再获得构成它的一系列边。在当前情况下只能获得一条边,因为我们用单个圆形构造了整个几何形状,因此只取边列表中的第一项,继而获得构成该形状的曲线。每条边都有一个曲线,几何图元就是基于它而成。 |
|||
如果您想了解更多请前往[[Topological data scripting|拓扑数据脚本]]页面。 |
|||
== 教程 == |
== 教程 == |
||
* [[Import_from_STL_or_OBJ|从STL或OBJ文件中导入数据]] : 如何在FreeCAD中导入STL/OBJ文件。 |
* [[Import_from_STL_or_OBJ|从STL或OBJ文件中导入数据]] : 如何在FreeCAD中导入STL/OBJ文件。 |
||
* [[Export_to_STL_or_OBJ|导出STL或OBJ文件]] : 如何从FreeCAD中导出STL/OBJ文件 |
* [[Export_to_STL_or_OBJ|导出STL或OBJ文件]] : 如何从FreeCAD中导出STL/OBJ文件 |
||
* [[Whiffle_Ball_tutorial|Whiffle球教程]] : 如何使用零件模块 |
* [[Whiffle_Ball_tutorial|Whiffle球教程]] : 如何使用零件模块 |
||
</div> |
|||
* [[Import_from_STL_or_OBJ|Import from STL or OBJ]] : How to import STL/OBJ files in FreeCAD |
|||
* [[Export_to_STL_or_OBJ|Export to STL or OBJ]] : How to export STL/OBJ files from FreeCAD |
|||
* [[Whiffle_Ball_tutorial|Whiffle Ball tutorial]] : How to use the Part Module |
|||
{{Docnav |
{{Docnav |
Revision as of 11:57, 24 August 2020
简介
FreeCAD的实体建模能力都是基于 Open Cascade Technology (OCCT)内核——一种具有创建与处理高级3D几何体等特性的专业级CAD系统。零件工作台(Part Workbench)是一种建立于OCCT库之上的层级,为用户提供了访问OCCT几何图元与函数的功能。每种工作台(如底图工作台, 草图工作台, 零件设计工作台等等)的一切2D与3D绘制功能其实都是基于零件工作台暴露出的函数实现的。因此,可以认为零件工作台是FreeCAD建模功能的核心组件。
以零件工作台创建的对象相对简单;为了构建更为复杂的几何图形,可以为之运用布尔运算(并集与减运算)。此建模范式就是尽人皆知的构造实体几何 (CSG) 工作流程,它是早期CAD系统中所用的传统方法。另一方面,零件设计工作台(PartDesign Workbench)还提供了更为现代的工作流程来构建几何图形:它利用参数化方式来定义草图,再将其挤压成型为基本的实体对象,最后通过参数化变换(特征编辑)来修改模型,直到用户获取预期的最终模型为止。
零件对象比网格工作台(Mesh Workbench)创建的网格对象更为复杂,因为用户可以对前者执行更为高级的操作,如连续的布尔运算、修改历史与参数化处理。
零件工作台是最基础的层级,它为FreeCAD中的其他工作台暴露出OCCT的各种绘制函数
工具
这些工具皆位于Part菜单。
图元
以下这些工具用于创建图元对象。
- Box: 根据指定的规格绘制一个立方体
- Cylinder: 根据指定的规格绘制一个圆柱体
- Sphere: 根据指定的规格绘制一个球体
- Cone: 根据指定的规格绘制一个圆锥体
- Torus: 根据指定的规格绘制一个环面(torus)(圆环 (ring))
- CreatePrimitives: 一种用于创建各类参数化几何图元的工具
- Shapebuilder: 一种利用各种参数化几何图元创建更加复杂几何图形的工具
修改对象
这些工具用于修改已存在的对象。通过它们即可选取待修改的对象。
- Thickness: 镂空一个实体,在选中的面上留下开口。
- Projection on surface: 向表面上投影logo、文本或任意表面、连线、边。可以为投影部分创建一个示例或连线。(v0.19)
- Compound Tools:
- Make compound: Creates a compound from the selected objects.
- Explode Compound: Tool to split up compounds of shapes
- Compound Filter: The CompoundFilter can be used to extract the individual pieces.
- Join features: smart booleans for walled objects (e.g., pipes) introduced in version 0.16
- Connect: Connects interiors of objects introduced in version 0.16
- Embed: Embeds a walled object into another walled object introduced in version 0.16
- Cutout: Creates a cutout in a wall of an object for another walled object introduced in version 0.16
- Splitting tools: introduced in version 0.17
- Boolean fragments: makes all the pieces that can be obtained by Boolean operations between objects introduced in version 0.17
- Slice a part: tool to split shapes by intersection with other shapes
- Slice: Splits an object into pieces by intersections with another object introduced in version 0.17
- XOR: removes space shared by even number of objects (symmetric version of Cut) introduced in version 0.17
- Defeaturing: introduced in version 0.18
- Section: Creates a section by intersecting an object with a section plane
- Cross sections...: Creates one or more cross-sections through a selected shape
- Attachment: attachment is a utility to attach an object to another one.
Measure
File:Std Measure Menu.png Measure: Allows linear and angular measurement between points, edges, and faces.
- Measure Linear allows you to make linear measurements.
- Measure Angular allows you to make angular measurements.
- Measure Refresh updates the measurements on screen.
- Clear All Clears all measurements.
- Toggle All shows or hides all measurements.
- File:Part Measure Toggle 3d.svg Toggle 3D shows or hides 3D measurements.
- Toggle Delta shows or hides delta measurements.
其他工具
- Import CAD: 您可利用此工具为当前文档添加*.IGES、*.STEP、*.BREP文档。
- Export CAD: 您可利用此工具将一个零件对象导出至一个*.IGES、*.STEP、*.BREP文件。
- Shape from Mesh: 根据一个网格对象创建一个几何形状对象。
- Convert to solid: 将一个几何形状对象转换为一个实体对象。
- Reverse shapes: 调转选中对象所有表面上的法线方向。
- File:Part CreateSimpleCopy.svg Create simple copy: 为选中的对象创建一个简单的副本。
- Refine shape: 通过去除不必要的线条来清理表面。
- Check geometry: 检测选中对象的几何体是否存在错误。
- Measure: 令用户可以实现点/边/面间的线性测量与角度测量。
- Attachment: 本工具的功能为令一个对象附着于另一对象之上。
- Create a copy:
- Create simple copy: Creates a simple copy of the selected object.
- Create transformed copy: creates a transformed copy of the selected object. introduced in version 0.19
- Create shape element copy: creates a copy from an element (vertex, edge, face) of the selected object. introduced in version 0.19
- Refine shape: Cleans faces by removing unnecessary lines.
- Check geometry: Checks the geometry of selected objects for errors.
- Appearance: determines appearance of the whole part (color transparency etc.).
- Set colors: assigns colors to part faces.
首选项
- Preference ... 导入 导出
脚本
参见: 零件脚本
教程
- 从STL或OBJ文件中导入数据 : 如何在FreeCAD中导入STL/OBJ文件。
- 导出STL或OBJ文件 : 如何从FreeCAD中导出STL/OBJ文件
- Whiffle球教程 : 如何使用零件模块
- Import from STL or OBJ : How to import STL/OBJ files in FreeCAD
- Export to STL or OBJ : How to export STL/OBJ files from FreeCAD
- Whiffle Ball tutorial : How to use the Part Module
- Primitives: Box, Cylinder, Sphere, Cone, Torus, Tube, Create primitives, Shape builder
- Creation and modification: Extrude, Revolve, Mirror, Fillet, Chamfer, Make face from wires, Ruled Surface, Loft, Sweep, Section, Cross sections, 3D Offset, 2D Offset, Thickness, Projection on surface, Attachment
- Boolean: Make compound, Explode Compound, Compound Filter, Boolean, Cut, Fuse, Common, Connect, Embed, Cutout, Boolean fragments, Slice apart, Slice, XOR
- Measure: Measure Linear, Measure Angular, Measure Refresh, Clear All, Toggle All, Toggle 3D, Toggle Delta
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub