| Topic |
|---|
| 建模 |
| Level |
| 初学者 |
| Time to complete |
| 1 小时 |
| Authors |
| GlouGlou |
| FreeCAD version |
| 0.17或以上版本 |
| Example files |
| See also |
| Creating a simple part with Part WB, Creating a simple part with Draft and Part WB |
本教程旨在通过一个实例,向 FreeCAD 初学者介绍一些基本功能。 在学习了用户入口的基础内容之后, 您将能够逐步完成第一个零件的建模。
本教程将涵盖以下内容:
创建一个新文档,然后通过 Part Design 选择工作台,方法是使用探索界面 (在链接图片中标记为 10) 或通过 视图 → 工作台 菜单。FreeCAD 启动后,顶部将显示工具栏,左侧为组合视图,右侧为 3D 视图。
创建实体:
点击 创建实体。
注意: 不要将图标为蓝色的“创建实体”与图标为黄色的“新零件”混淆。
在组合视图侧边栏的“模型”选项卡中,文档标签(由于我们尚未保存文档,当前为“未命名”)下会出现一个标记为“Body”的新对象。
实体是一个容器,按照零件设计特征顺序排列以形成单个实体。它包含自身的参考轴和参考平面。在模型树中它以浅蓝色高亮的方式显示,这表示它处于活动状态,也就是说我们可以编辑其中包含的元素,也可以向其中添加新元素。如果未高亮显示,请双击它,或右键单击并在上下文菜单中选择 活动实体。
“实体”标签前有一个与上图相同的蓝色图标,以及一个箭头或加号(具体取决于您的操作系统)。点击“实体”前面的箭头或加号可展开其内容。此时,它仅包含一个名为“原点”(有的版本可能为 “原点001”)的元素。该“原点”前面同样有一个箭头或加号。点击它以展开其内容。这将显示下图所示的上述参考轴和参考平面:

新建的活动实体及其展开的内容。
原点 呈灰显状态,表示其内容在 3D 视图中不可见。您可以通过选中原点并按键盘上的空格键,使其内容在 3D 视图中可见。此时原点在树中将显示为黑色。再次按空格键可将其内容在 3D 视图中隐藏。再次单击原点前的箭头或加号,可在模型树中折叠其内容。
在继续之前,让我们借此机会重命名该实体。
重命名实体:
在模型树中,右键单击“Body”。选择“重命名”,输入名称(例如“Body part1”),然后按Enter键确认。
创建草图:
现在我们将绘制定义零件大致外形的草图。草图是一种图形,描述了一个将要应用于特征上以生成形状的轮廓(截面)。 它可以是"正向的"或"增材的", 例如"凸台"; 也可以是"负向的"或"减材的", 例如"凹槽"。
在此,由于零件沿 Y 轴方向的整体形状较为规则(等截面的),我们将沿该轴创建凸台。
点击 新建草图按钮。此时,组合视图切换到任务选项卡,并显示选择附件对话框。该对话框要求您选择一个用于附着草图的平面,并列出所有可用平面。请选择 XZ平面 (基准平面),然后点击OK。此时界面发生变化,草图工作台接管控制,其工具栏出现在3D视图上方。我们便进入了该几何体的XZ平面,开始绘制草图。
为了方便绘制草图,请在左侧“任务”面板的“草图编辑”中将以下选项设置为:
我们将绘制以下草图:
让我们从第一个线段开始:
选择 线 工具。点击原点,首先确保鼠标指针旁边和右方出现一个红色小点。接下来,在 X 轴上向右约 10 个网格(或约 100 mm)处点击。如果此时线段长度并非正好为 100 毫米,也没关系,我们稍后会为其指定一个固定尺寸来约束该长度。
对其他线段执行同样的操作,尝试将光标对准您已创建的点,这些点应会亮起黄色。这意味着这些点将变为重合(约束)。按一次Esc键即可停止使用线工具。您应该会得到大致如下的效果:
注意到您绘制的线段上方和旁边的小红线条:这些是水平和垂直约束符号。您的线条被强制保持水平或垂直。还要注意左侧的弧形小符号:这意味着该点被固定到 Z 轴上。
现在用鼠标左键选中不同的线段,在按住左键的同时拖动鼠标,尝试移动它们:有些可以自由移动,有些则不能。
设置尺寸:
在组合视图的“任务”面板中,您可以看到已绘制草图元素的自由度(degrees of freedom)数量:该数值应约为 6。应用约束的目标是将自由度数量减少到 0。
此时,斜线应该可以自由旋转:我们将为其添加一个角度尺寸来将其固定。
点击斜线,然后点击底部那条线;选中后,这两条线会变为深绿色;然后点击 角度尺寸 图标.
输入 30° 值。现在两条线有了固定的角度。该约束创建在草图左侧;用鼠标将其移到轮廓内部。
现在我们将用一个尺寸来约束底部那条线:选中它,然后点击 水平尺寸.
输入值 100 毫米(mm)。现在,右侧的垂直线正好与坐标原点右侧第 10 个网格对齐。
通过选择草图中最高线的最左侧点,然后选择原点,来设置轮廓的总高度。点击 垂直尺寸, 输入 50 mm 的值。
对斜线的水平长度执行同样的操作,再添加一个 50 mm 的水平尺寸约束。
将尺寸标注从轮廓线处移开,以便更清晰地查看。现在,您应该看到类似下图的效果:
我们注意到,自由度数量已减少到 2 个,这些是仍然开放的端点。
绘制圆弧:
点击 从圆心创建圆弧,将中心大致定位在 x = 80、y = 30 处;然后点击上方水平线的右端点,以定义圆弧的第一个起点;接着点击右侧垂直线的上端点,以定义圆弧的终点(确保在点击之前这些点已高亮显示为黄色)。
为圆弧添加半径尺寸:选择圆弧,然后点击 半径尺寸,再输入数值 20 mm.
现在让圆弧与其所连接的直线相切:依次选择圆弧、顶部直线,然后点击 相切/共线约束。此时会弹出 草图替换约束 消息, 点击OK。在圆弧的另一侧重复同样的相切约束操作。
我们分两步完成了草图的创建,但也可以先完整绘制出轮廓,然后再对其进行完全约束。
完全受约束的草图:
如果你操作正确,应该会得到以下结果:
The sketch has become green, which means that it is fully constrained. There is no longer any ambiguity, everything is perfectly defined. This is confirmed by the solver message at the top left. Also note that the center of the arc has moved slightly, indeed giving these last three constraints, FreeCAD has calculated the true position of the center.
If your sketch is not yet green, one or more points are not coincident (2 points can be superimposed yet not be coincident). Make a small window (capture window) around a point to select, and create a Coincident constraint. Note: don't mistake the Coincident constraint for the Sketcher Point; while their icons are very similar, the latter has a larger icon; it adds a lone point in the sketch.
Proceed in the same way with all the points.
If your sketch is still not green, verify that all lines (but the slanted one) have either a Horizontal or
Vertical constraint, and add if necessary.
Click on Close in the Tasks tab, at the top left corner. We automatically exit the Sketcher workbench, and the Part Design workbench is activated again. The Combo View switches back to the Model tab. If you left your Body part1 expanded, you will see a new Sketch element below Origin, and nested under the Body.
At this point, let's save our document. Give it a name (for example "tutorial1", or any name that you find relevant). It is good practice to save your document often, for example after completing a sketch or a feature.
Click on Isometric view then
Fit all, which gives a centered 3D isometric view.
Click on Pad, enter a length of 30 mm. Click OK, the shape is completed. In the Model tree, a Pad object (that we call feature) appears instead of the Sketch. In fact, it has claimed Sketch, since it is based on it; clicking on the arrow or plus sign in front of Pad to expand it will reveal the Sketch underneath, which was automatically made hidden (its label is grayed out).
Note that the shape created forms a solid.
Creating the hole
Click on the top (square) side of the part and click the icon to create a new sketch. FreeCAD creates a new sketch attached to this face. So we are on a plane parallel to the absolute plane XY, but offset in height from the height of the piece, i.e. 50 mm.
You can switch the 3D window to an isometric view or stay in top view
. At any time, you can return to Sketch view (the view is oriented to face the sketch plane) using the
Sketcher ViewSketch icon.
Note that the origin of this new sketch is that of the body. They may be different, but here are confounded with the absolute origin.
With the Circle tool, click roughly in the center of the face and make a circle of any radius.
Select the circle then create a Radius constraint, enter a value of 5 mm.
Select the center of the circle then create a Lock constraint; double-click on the horizontal dimension and enter -65 mm (here we indicate a position relative to the origin of the sketch). Do the same for the vertical dimension (15 mm). The circle takes its correct position and the sketch becomes green, indicating it is fully constrained:
Close the sketch; in the Model tree, a new Sketch001 object has appeared below Pad. While Sketch001 is still selected, click on Pocket.
Pocket is a feature called "subtractive", it removes material from our part, here in the form of a cylinder since the sketch is a circle. Set "Through all" to completely cut the part. Press OK to complete. In the Model tree, a new element labelled Pocket appears at the bottom of the Body part1, and claims Sketch001.
It is possible to change the color of the part, it is often useful to distinguish a part among others. The transparency of the piece can also be modified, which is useful for visualizing its internals.
Select the Body part1 body; make sure that the Model tab of the Combo View is selected and go to the lower part of the Combo View, then click on the View tab; locate the Shape Appearance property; you may need to use the vertical scroll bar to the right to find it. You can also widen the Property column: hover your mouse pointer over the separating line between the Property and Value headers; when the pointer turns into a double-sided arrow, press and hold your left mouse button and drag sideways, then release. In the right column, click on the gray square, which opens the Select Color dialog. Pick another color then click OK. Next, again in the View tab, change the value of Transparency, for example to 50 and press Enter to complete (0 = totally opaque, 100 = totally transparent).
The hole is now visible inside the part. This is often useful for seeing the hidden or internal faces of the model.
You can also vary "Line Color" and "Line Width" to change the line thickness and the color of the part outline.
Go to the View menu and select Toggle axis cross. These are the absolute axes. You should see in the 3D view, the 3 axes X, Y, Z in red, green and blue. This landmark will help us to orient ourselves in space. This landmark is fixed and immutable, it is either the view that rotates or the object that rotates in this space.
Select the Body; at the bottom of the Combo View on the left, you can see this (the Data tab needs to be on the foreground, you may need to click on the Data tab to make it visible):
Click on the three small dots, i.e., the ellipsis (if they don't appear, click on the Value section of the Placement field); this opens a new dialog in the Tasks panel. Using the arrows you can vary the position and angles of the part. It is actually the position of the body (so its origin) that moves in space, the orientation of the 3D view does not change.
Another method: in the Combo View, select the Body and click on the right button of the mouse, then select Transform. A view like this appears:
Hold and drag the cones along the axes or the spheres to move the body in all directions.
Validate. Then reset angles and coordinates to 0.
It may be useful to know the dimensions of some parts of the sketch, from the internal calculation of FreeCAD. It can be used just for reference, or use them later to set other dimensions for example.
In the Model tree, if necessary expand Body part1 then Pad to show the first Sketch. Double-click on it (or right-click and select Edit sketch in the contextual menu) then click on Toggle Constraint. (Note: depending on your computer display resolution, this icon may not be visible. At the right end of the Constraints toolbar, you may find a » button. Click on it to expand and access collapsed icons.) Notice how the buttons for the dimensional constraints change color from red to blue. From now on, we can create reference dimensions rather than dimensional constraints: they will be blue and will have no influence on the shapes of the sketch from which they come, they are calculated automatically.
You can display these dimensions for example:
We can see for example that the arc has a length of 20 since it's tangent with the edges.
We can also see that FreeCAD calculates the left face (50-50xTAN 30 °), as well as the distance dimension of the axis of the arc with the origin.
During modeling, you can vary the dimensions of the model. It's very simple: for the thickness of the piece, double-click Pad, then enter a new value, 40mm for example. In the lower part of the combo view, you can change this value as well. Validate, the shape of the object has changed.
Do the same for the total length of the piece: double-click on Sketch, then double-click on the 100 mm dimensional constraint, change it to 110 mm then validate.
We can see that the piece was enlarged, but the hole is no longer centered in the middle of the top face. That's because it has been constrained to the sketch origin. Which does not necessarily correspond to what one would like, the hole should remain in the center, whatever the size of the face.
First method using external geometry.
Edit again the sketch of the hole and erase its horizontal and vertical distance constraints.
Then click on External Geometry.
We will now create two lines in the sketch, but extracted from a shape (or feature) external to this one and previously defined: that of the Pad.
Click on a vertical edge at the top of the part. For example, the edge slope side.
A new magenta line will appear above the edge. Repeat for the other edge, on the rounded side.
We can now use these lines (and especially their end points) to centre the circle, however we must add two construction lines: for example the diagonals.
Click on Construction Mode, we switch to construction mode: the lines will be blue and will be discarded outside of the sketch editing mode. They will allow to fix the center of the circle. Create the diagonals in the same way that you drew the first lines. Make sure all points are coincident.
Then select the center of the circle, then the two blue diagonal lines and click on Coincident Constraint (Unified), the circle must be centred at the intersection of the diagonals, that is at the center of the face. The sketch must be green, completely constrained (it is essential). Note that besides the radius of the circle, it is no longer necessary to create dimensional constraints.
Please note that in addition to switching the the toolbar to construction mode, the Construction Mode button can also switch individual Sketcher elements to construction mode if they have been selected. If you accidentally switch an element to construction mode, you may get an error when you exit the sketch.
Leave the sketch, we see that the circle is well centred. (The pocket feature was not deleted, but modified). If you change the dimensions of the part again, the thickness or the length, the circle will remain centered on the face.
Avoid construction lines:
It is often possible to avoid creating construction lines. You can edit the sketch again, erase the construction lines and use a Symmetric constraint between the two opposite vertices of the external geometry lines and the centre of the circle (select points in this order):
We get exactly the same result for the position of the hole. In fact, thanks to the constraints available in the Sketcher workbench, there are many possible methods. This example shows that it is often better to choose the simplest method, thus limiting the number of objects created as well as the errors that might result.
Second method using a datum plane.
Here is another, faster method that is possible since version 0.17: the use of a datum plane and its attachment.
Start by erasing the "Pocket" function as well as the sketch of the hole. Select the top face and click Datum point: create a datum point in the active body. The attachment mode chosen must be "Center of mass".
As the face is rectangular, its center of mass corresponds to the center of its diagonals. Validate, and a datum point is created.
Select the top face again and while holding down the CTRL key, select the point you just created in the Model tree, release CTRL and click Datum plane. A reference plane is created with the origin of the point. Click OK.
It is now very easy to center the circle! Select from the Model tree or in the 3D view the plane you created, and click on Create a sketch, a sketch is created with as origin, the origin of the plane. Then just trace the 5 mm radius circle on this origin, then validate (the sketch must be green imperatively).
You get with "Pocket", as created previously, the hole and it will always be centered.
This tutorial is completed, save this file, you can have fun exploring various features. Change other dimensions, make other shapes, put other holes on other faces, it is when making mistakes that we progress!
You can also continue with this other tutorial of a slightly more complicated part: