Manual:Modeling for product design/zh-cn

产品设计 原本是商业术语，但在 3D 领域，通常意味着建模的时候，心里想着将来 3D 打印，或更一般地说，由机器（例如 3D 打印机或 CNC 机床）制造出来.

在进行 3D 打印时，确保对象是“实体”的非常重要. 因为它们将成为真实的、实体的物体，这是显而易见的. 当然，它们可以为空心的. 但是，您始终需要清楚地知道哪些点在材料内部，哪些点在材料外部，因为 3D 打印机或数控机床需要准确地知道哪些地方填充了材料，哪些没有填充. 因此，在 FreeCAD 中，PartDesign Workbench 是构建这些零件的完美工具，因为它将始终为您保证，你的物体是实体，可构建.

为了说明 PartDesign 的工作方式，我们练习建模著名的 Lego 玩具的这款模型.



乐高积木有个很酷的特色——容易在互联网上获得零件的尺寸，至少对于标准件而言是这样. 建模之后，在 3D 打印机上打印，都很容易. 带着点耐心（3D 打印通常需要大量的调整和微调），可以制作出完全兼容的部件，完美地匹配原始乐高积木. 下面的示例将制作比原始尺寸大 1.5 倍的零件.

这里专门使用 Sketcher 和 PartDesign 工具. 由于Sketcher 工作台中的所有工具都包含在 PartDesign 工作台里了，我们可以就在 PartDesign 中工作，不需要在两者之间来回切换.

PartDesign 对象完全基于 Sketches. Sketch 是一个 2D 对象，由线段（线，圆弧或椭圆弧）和约束组成. 这些约束可以应用于线段，或其端点和中心点，并强制几何元素满足某些规则. 例如，可以在线段上施加垂直约束以强制它保持垂直，或者在端点上施加位置（锁定）约束以禁止它移动. 当草图的约束数量刚好时，草图的任何点都无法再移动了，称为完全约束的草图. 当存在冗余约束时，移除某些约束也不会令几何体允许移动，称为过度约束. 这应该避免，如果出现这种情况，FreeCAD 会通知你.

草图具有一个编辑模式，你可以在其中更改其几何形状和约束. 完成编辑并退出编辑模式后，草图就会像 FreeCAD 中的任何其他对象一样运行，它们可以作为所有零件设计工具的构建块，也可以在其他如 Part 或 Arch 工作台中使用. Draft workbench 还有一个工具可以将 Draft 对象转换为草图，反之亦然.


 * 我们首先建模一个立方体形状，它将成为我们乐高积木的基础. 稍后我们将雕刻内部，并在其顶部添加8个点. 所以，让我们首先制作一个矩形草图，然后对其进行拉伸：
 * 切换到 PartDesign Workbench
 * 点击 [[Image:Sketcher_NewSketch.svg|16px]] New Sketch 按钮. 将出现一个对话框，询问你想在何处创建草图，选择 XY 平面，即 "地面" 平面. 草图将被创建并立即切换到编辑模式，视图将旋转以正交看向你的草图.
 * 现在我们可以绘制一个矩形，通过选择 [[Image:Sketcher_CreateRectangle.svg|16px]] Rectangle 工具并点击两个角点. 你可以在任何地方放置这两点，因为他们的正确位置将在下一步中设置.
 * 你会注意到，我们的矩形自动添加了一些约束：垂直段收到了垂直约束，水平段收到了水平约束，每个角点都收到了点对点约束，将各段粘合在一起. 你可以尝试通过用鼠标拖动其线条来移动矩形，所有的几何形状都会遵守这些约束.




 * 现在，让我们添加三个额外的约束：
 * 选中垂直段中的一个，然后添加一个 [[Image:Constraint_VerticalDistance.svg|16px]] 垂直距离约束. 将其设定为 23.7 毫米.
 * 选中水平段中的一个，然后添加一个 [[Image:Constraint_HorizontalDistance.svg|16px]] 水平距离约束. 将其设定为 47.7 毫米.
 * 最后，选中角点中的一个，然后选择原点（就是红色和绿色轴线交叉处的点），然后添加一个 [[Image:Constraint_PointOnPoint.svg|16px]] 重合约束. 矩形将会跳至原点，你的草图会变成绿色，这意味着它现在已经完全被约束了. 你可以尝试移动其线条或点，但它们不会再移动.



请注意，最后一个点对点的约束并非绝对必要. 你并不一定要使用完全约束的草图进行工作. 然而，如果我们打算将这个块进行3D打印，那么将我们的部件保持在原点附近将是必要的（原点将是打印机头可以移动的空间的中心）. 通过添加这个约束，我们确保了我们的部件始终会"锚定"在那个原点.

Share


 * 现在我们的基础草图已经准备好了，我们可以通过点击任务面板顶部的 关闭 按钮或简单地按 Escape 键来退出编辑模式. 如果后续有需要，我们可以在树状视图中双击草图随时重新进入编辑模式.
 * 我们来通过使用 [[Image:PartDesign_Pad.svg|16px]] Pad 工具并设定距离为 14.4 毫米来将其拉伸. 其他选项可以保持默认值：



Pad 的行为很像我们在上一章中使用的 Extrude 工具. 然而，它们之间还是有一些差异的，主要的差异在于，Pad 不能被移动. 它永远附着在它的草图上. 如果你想改变 Pad 的位置，你必须移动基础草图. 在当前的上下文中，我们希望确保没有任何东西会移出位置，这是一种额外的安全保障.


 * 现在，我们将使用 [[Image:PartDesign_Pocket.svg|16px]] Pocket 工具来挖掘块的内部，这是 PartDesign 版本的 Part Cut. 为了创建一个口袋，我们将在块的底部面创建一个草图，这将用于移除块的一部分.
 * 在选中底部面的情况下，按下 [[Image:Sketcher_NewSketch.svg|16px]] 新建草图 按钮.
 * 在面上画一个矩形.




 * 我们现在将根据底面约束矩形. 为了做到这一点，我们需要使用 [[Image:Sketcher_External.svg|16px]] 外部几何 工具 "导入" 面的一些边缘. 在底面的两条垂直线上使用此工具：



你会注意到，只有基面的边缘才能通过这个工具添加. 当你创建一个带参考面的草图时，会在该面和草图之间创建一个关系，这对于后续操作很重要. 你总是可以稍后用 映射草图 工具将草图重新映射到另一个面.


 * The external geometry is not "real", it will be hidden when we leave edit mode. But we can use it to place constraints. Place the 4 following constraints:
 * Select the top left point of the rectangle and the top point of the imported line and add a [[Image:Constraint_HorizontalDistance.svg|16px]] Horizontal Distance Constraint of 1.8mm
 * Select again the top left point of the rectangle and the top point of the imported line and add a [[Image:Constraint_VerticalDistance.svg|16px]] Vertical Distance Constraint of 1.8mm
 * Select the bottom right point of the rectangle and the bottom point of the right imported line and add a [[Image:Constraint_HorizontalDistance.svg|16px]] Horizontal Distance Constraint of 1.8mm
 * Select again the bottom right point of the rectangle and the bottom point of the right imported line and add a [[Image:Constraint_VerticalDistance.svg|16px]] Vertical Distance Constraint of 1.8mm




 * Leave edit mode and we can now perform the pocket operation: With the sketch selected, press the [[Image:PartDesign_Pocket.svg|16px]] Pocket button. Give it a length of 12.6mm, which will leave the upper face of our pad with a thickness of 1.8mm (remember, the total height of our pad was 14.4mm).




 * We will now attack the 8 dots on the top face. To do this, since they are a repetition of a same feature, we will use the handy [[Image:PartDesign_LinearPattern.svg|16px]] Linear pattern tool of the Part Design Workbench, which allows to model once and repeat the shape.
 * Start by selecting the top face of our block
 * Create a [[Image:Sketcher_NewSketch.svg|16px]] New sketch.
 * Create two [[Image:Sketcher_Circle.svg|16px]] circles.
 * For each circle, select it and add a [[Image:Sketcher_ConstrainRadius.svg|16px]] Radius Constraint of 3.6mm to each of them
 * Import the left edge of the base face with the [[Image:Sketcher_External.svg|16px]] External geometry tool.
 * Place two vertical constraints and two horizontal constraints of 6mm between the center point of each circle and the corner points of the imported edge, so each circle has its center at 6mm from the border of the face:




 * Notice how, once again, when you lock the position and dimension of everything in your sketch, it becomes fully constrained. This always keeps you on the safe side. You could change the first sketch now, everything we did afterwards would keep tight.
 * Leave edit mode, select this new sketch, and create a [[Image:PartDesign_Pad.svg|16px]] Pad of 2.7mm:




 * Notice that, as earlier with the pocket, since we used the top face of our base block as a base for this latest sketch, any PartDesign operation we do with this sketch will correctly be built on top of the base shape: The two dots are not independent objects, they have been extruded directly from our brick. This is the great advantage of working with the Part Design Workbench, as long as you take care of always building one step on top of the previous one, you are actually building one final solid object.
 * We can now duplicate our two dots four times, so we get eight. Select the latest Pad we just created.
 * Press the [[Image:PartDesign_LinearPattern.svg|16px]] Linear pattern button.
 * Give it a length of 36mm (which is the total "span" we want our copies to fit in), in the "horizontal sketch axis" direction, and make it 4 occurrences:




 * Once again, see that this is not just a duplication of an object, it is a *feature* of our shape that has been duplicated, the final object is still only one solid object.
 * Now let's work on the three "tubes" that fill the void we created on the bottom face. We have several possibilities: create a sketch with three circles, pad it then pocket it three times, or create a base sketch with one circle inside the other and pad it to form the complete tube already, or even other combinations. Like always in FreeCAD, there are many ways to achieve the same result. Sometimes one way will not work the way we want, and we must try other ways. Here, we will take the safest approach, and do things one step at a time.
 * Select the face that is at the bottom of the hollow space we carved earlier inside the block.
 * Create a new sketch, add a circle with a radius of 4.8825mm, import the left border of the face, and constrain it vertically and horizontally at 10.2mm from the upper corner of the face:



If you have trouble to select features hiding part of the model can help. To hide a feature select it from tree view and press Space-key to toggle visibility.


 * Leave edit mode, and pad this sketch with a distance of 12.6mm
 * Create a linear pattern from this last pad, give it a length of 24mm and 3 occurrences. We now have three filled tubes filling the hollow space:




 * Now let's make the final holes. Select the circular face of the first of our three "pins"
 * Create a new sketch, import the circular border of our face, create a circle with a radius constraint of 3.6mm, and add a [[Image:Constraint_PointOnPoint.svg|16px]] Point on Point Constraint between the center of the imported circle and our new circle. We now have a perfectly centered circle,and once again fully constrained:




 * Leave edit mode, and create a pocket from this sketch, with a length of 12.6mm
 * Create a linear pattern from this pocket, with a length of 24mm and 3 occurrences. That's the last step, our piece of lego is now complete, so we can give it a nice color to mark our victory!



You will notice that our modeling history (what appears in the tree view) has become quite long. This is precious because every single step of what we did can be changed later on. Adapting this model for another kind of brick, for example one with 2x2 dots, instead of 2x4, would be a piece of cake, we would just need to change a couple of dimensions and the number of occurrences in linear patterns. We could as easily create bigger pieces that don't exist in the original Lego game.

But we could also want to get rid of the history, for example if we are going to model a castle with this brick, and we don't want to have this whole history repeated 500 times in our file.

There are two simple ways to get rid of the history, one is using the Create simple copy tool from the Part Workbench, which will create a copy of our piece that doesn't depend anymore on the history (you can delete the whole history afterwards), the other way is exporting the piece as a STEP file and reimporting it.

Assembling

But the best of both worlds also exists, which is the Assembly2 Workbench, an addon that can be installed from the FreeCAD-addons repository. This Workbench is named "2" because there is also an official built-in Assembly Workbench in development, which is not ready yet. The Assembly2 Workbench, however, already works very well to construct assemblies, and also features a couple of object-to-object constraints which you can use to constrain the position of one object in relation to another. In the example below, however, it will be quicker and easier to position the pieces using Draft Move and  Draft Rotate than using the Assembly2 constraints.


 * Save the file as it is now
 * Install the Assembly2 Workbench and restart FreeCAD
 * Create a new empty document
 * Switch to the Assembly2 workbench
 * Press the Import a part from another FreeCAD document button
 * Select the file we saved above
 * The final piece will be imported in the current document. The Assembly2 workbench will determine automatically what is the final piece in our file that needs to be used, and the new object stays linked to the file. If we go back and modify the contents of the first file, we can press the Update parts imported into the assembly button to update the pieces here.
 * By using the Import a part from another FreeCAD document button several times, and moving and rotating the pieces (with the Draft tools or by manipulating their Placement property), we can quickly create a small assembly:



Downloads


 * The model produced during this exercise: https://github.com/yorikvanhavre/FreeCAD-manual/blob/master/files/lego.FCStd

延伸阅读


 * The Sketcher
 * The Part Design Workbench
 * The Assembly2 Workbench