Outils pour utilisateurs

Outils du site


issue123:freecad

Ceci est une ancienne révision du document !


In this series, we will be examining the world of FreeCAD, an open-source CAD modelling application that is still in Beta, but has been gaining acceptance in recent years. Naturally, it is readily available in the Ubuntu repositories. In the third article on using FreeCAD, we created a complex 3D object representing a Y-junction between two pipes of different diameters. In this part, we will go back to basics and examine how constraints can be used to draw complex planar shapes, that can then be used as a basis to create figures in 3D. Users of traditional CAD software such as AutoCAD or LibreCAD are well accustomed to two sets of techniques that help draw complex shapes from individual elementary shapes such as lines or arcs. The first set of techniques is the different ways in which an elementary shape can be defined in these applications. For instance, a straight-line segment may be defined by indicating both ends of the segment. But it could also be defined as the tangent to a circle at a certain point, and with a specific length. A further possibility is to define a line segment as being parallel to a previous segment of the same length and offset to a specific distance. As for circles, they may be defined from a center and a radius, or from three points that are not on the same straight line, and so forth.

Dans cette série, nous examinerons le monde de FreeCAD, une application Open Source de modélisation par CAO qui est encore en bêta, mais qui a reçu un bon accueil ces dernières années. Naturellement, elle est déjà disponible dans les dépôts d'Ubuntu. Dans le troisième article sur l'utilisation de FreeCAD, nous avons créé un objet complexe en 3D représentant une jonction en Y de deux tuyaux de diamètres différents.

Dans ce numéro, nous reviendrons aux bases et examinerons comment des contraintes peuvent être utilisées pour dessiner des formes planes complexes, qui peuvent ensuite être utilisées comme bases pour créer des figures en 3D.

Les utilisateurs de logiciels traditionnels de CAO tels que AutoCAD ou LibreCAD sont bien habitués aux deux jeux de techniques qui aident à la création des formes complexes à partir de formes élémentaires indépendantes telles que des lignes et des arcs. Le premier jeu de techniques est les différentes façons par lesquelles une forme élémentaire peut être définie dans ces applications. Par exemple, un segment de ligne droite peut être défini en indiquant les deux extrémités du segment. Mais, il peut aussi être défini comme la tangente à un cercle en un certain point, avec une certaine longueur. Une autre possibilité est de définir le segment de ligne comme étant parallèle à un segment précédent de même longueur et décalé d'une certaine distance. Quant aux cercles, ils peuvent être définis par leur centre et leur rayon ou par trois points qui ne sont pas sur la même droite, ainsi de suite.

A second set of techniques that may be considered quite basic in traditional applications is the use of layers. In a program such as LibreCAD, default line width, color and style (dashed, dotted, …) may be defined for each layer. A handy technique is thus to place the main elements of each drawing in one layer, while another is used to indicate dimensions, and a third to draw auxiliary items to help construction. When exporting the drawing, individual layers may be hidden with a single mouse click. At this point in time, the use of such techniques is perhaps not as easily visible in FreeCAD version 0.15 as could be desired. As has been pointed out in a previous part of this series, this application is known to still be very much in development, so there is hope that such features may be made more accessible as the application evolves. Version 0.16 - in the repositories for Ubuntu 17.04 - already hints at the presence of layers within a sketch. In the meantime, users of version 0.15 - in the repositories for Ubuntu 16.04 LTS and Linux Mint 18 - can today work around these limitations by using other features that are more clearly available in the program. This is the subject of this article.

An example To visualize the problem, let us begin by drawing up a simple flat piece, with a geometry similar to that used in an engine connecting rod. This part is basically made up of two rings, one at each end, connected with two rectangular spars. The center of the rod has been removed, possibly to lighten the part. To draw this part in a traditional manner, the first step would be to create a layer that holds only auxiliary lines – that will not be part of the finished drawing. For instance, one could begin by drawing all the circles. Once the circles are defined, the external edge of the spars can be placed (in red). The easiest way in a traditional CAD application is to specify a line segment as tangent to both red circles, once for the upper spar and once for the lower. Then, the inner edge of each spar needs to be drawn (in green). There are several ways of doing this. The same procedure may be used, with each segment defined as tangent to the grey circles. An alternative way of doing it is to define the green segments as parallel to the red segments that have already been placed, while specifying an offset - in this case, 5mm. We can then create a second - main - layer, and draw the segments and arcs of the final part. Selecting snap-to-intersection instead of the more usual snap-to-grid allows us to carefully terminate each element precisely at the intersections between lines and circles.

On to FreeCAD To create the same part in FreeCAD, let us begin by creating a new project. Now, we could proceed as in the previous episodes, by going into the Draft workbench and setting up the elements of the drawing using the tools available there for drawing lines, circles and arcs. However, though we can snap element vertices to the grid, or even to another element, there is no way of ensuring that a line stays tangent to a circle or an arc. For this reason, we will go into another workbench, the Sketcher. Here, we will create a new Sketch object, within the X-Y (horizontal) plane. This type of object represents a flat drawing, considered as a separate entity from the rest of our project. Once editing the new Sketch, we can begin by changing the default grid size from 10 to 5mm, since the dimensions of our part are all multiples of 5mm. Let us draw the two circles that define the left ring of our part, with respective radii of 20 and 25mm. It is interesting to note how the shape of the mouse pointer changes when creating a new point. In a general situation, the shape is a red circle, with the new point’s coordinates in blue beside it. However, if we click on an existing point, a red dot shows up beside the circle. If we click in this situation, we can choose to link both points. This is ideal when we are drawing two circles with the same center. If, later on, we move one of the center vertices, both will move at the same time - and both circles will be displaced an equal distance.

Other options include placing the new point on a segment of an arc, thus linking the point to the arc. If we then displace one of the two objects, the movement of the other will equally be constrained. Likewise, when a line segment is drawn and one of the vertices has already been placed, a horizontal or a vertical constraint can be placed on the segment by placing the second vertex when the mouse cursor contains the corresponding red horizontal or vertical bar. Once the two circles have been created, we can inspect the number of elements created in the “Elements” window, and select each element by clicking on it. Once selected, each element can be moved around using the mouse. This is fine for the time being, but will introduce a difficulty when the connecting segments are placed to create the connecting rod itself: altering the position of a segment may very well end up by moving one of the circles that is connected to it, thus making sure the two elements remain in connection. We do not want this to happen; on the contrary, we want the circles to determine the position of the segments. So let us place a constraint on the position of each of our circles. Click on the center of the circles - which should be a single round dot - and then use the constraint toolbar to choose the “lock” constraint which has an icon shaped, rather appropriately, like a padlock.

Let us continue by drawing the remaining circles, and locking them into place. We should now see four constraints, two for each center (one horizontal and one vertical), within the “Constraints” window at the left of the screen. The four circles should look approximately like the image on the next page (top left). We have constrained (fixed) the position of the center of each circle. However, their radii are not yet constrained, and could be altered when connecting segments are added. To fix their size, select each circle in turn and select the “Fix de radius” constraint, a red circle with a bar on it, from the constraints toolbar. Our sketch should now change aspect, with all elements changing color to become green. This indicates our sketch is fully constrained: existing elements cannot be further moved, unless at least one of the constraints is lifted. We are now ready to place the connecting segments on our - now immobile - circles. Start by drawing a line segment from one of the external circles, to the other. By carefully placing the mouse, we should be able to constrain the segment’s vertices so that each remain on a circle - this is the symbol of a red arc with a dot in its center. However, it should rapidly become clear that this segment is not yet necessarily tangent to each circle. To impose this new set of constraints, click on the dot representing the segment terminal vertex, then click on the circle. Finally, choose the “Create a tangent” constraint. The operation will need to be repeated several times, once for each intersection between a segment and a circle. It may also be necessary to remove spurious horizontal constraints on our segments, if they should appear during construction.

The final result, with all four segments placed and the elements completely constrained, should appear like that shown below. Up until this point, we have been actively editing our Sketch object. We can now close this object, returning to the standard FreeCAD view, and examine our handiwork. All constraints have disappeared in the normal view, and we are left with our shape’s individual elements - all grouped together in a single planar Sketch object. Building the final shape What we have obtained so far is, in fact, just the auxiliary, constructive aides to help us place our final arcs and segments. It would be nice to see them in a different color and style, to help us distinguish between helper traces and elements belonging to the final drawing. There are two ways of going about this. The first is to exit Sketch edition. By clicking once on the Sketch, we can proceed down to the “Property” window, and change both “Line Color” and “Draw Style” for all lines in the Sketch in a single action. Then, we can proceed to the “Draft” workbench. Once here, we can use the drawing tools from the Draft toolbar (with yellow/black icons) to draw on top of the Sketch.

Intersections between Sketch elements can be made easily detectable if a point is placed at each intersection from within the Sketch. To do so, create a point using the tools with the icon with the red dot. When placing the point, snap to one of the elements creating the intersection, for example to the circle. Then click on the new point, click on the other element of the intersection - for example, a line segment - and create a new constraint of type “Fix a point onto an object”. The point should then be fixed by being constrained twice, once to each element, and thus should stay in place at the intersection. Once the points at the intersections have been created, lines in the Draft workbench and can be snapped to these points if the “Snap to intersection” option is chosen (the icon with a green ‘X’ from the snap toolbar). A second way of drawing the final shape of our part is to do it directly inside the Sketch. Go back into editing the Sketch object (double-click on the object), selecting all the lines and switch them all to “Construction mode” using tool . This will change their color to blue - and make them disappear from the Sketch when this is not being viewed from within edition mode. We can then proceed by creating the points at intersections, as needed. Continue by adding further elements to the Sketch object, taking these constructive elements as a guide. These elements, drawn in normal mode, will appear when not editing the Sketch. Since they are based upon other elements in constructive mode, some elements may need to be converted to normal mode using the same tool: .

At this point, we can use the Sketch object to print a diagram in two dimensions. However, we cannot use it directly to create a three-dimensional part. To do so, we must begin be going to workbench Draft, and there convert the Sketch object into a collection of drawing elements using the appropriate conversion tool: . Once this has been done, we can go to the Part workbench, extrude each object (the two circles and the two outline shapes) individually, and then combine them using boolean operations (Fusion and Cut out) to create the final piece in 3D, as described in Part 2 of this series. What next? In this article on using FreeCAD, we created a Sketch object, to place individual drawing elements such as lines, arcs and points, in a precise relationship to each other using constraints. We noted the use of Construction mode elements within the Sketch object, to aid construction of the complete diagram while not appearing in the final drawing. In the next part of the series, we will change scale altogether and work on an architectural project.

issue123/freecad.1502192533.txt.gz · Dernière modification : 2017/08/08 13:42 de d52fr