Will show you what kind of Edge this is, that is, if it is based on a line, an arc, etc. Edges are always made from such a base geometry, which is stored its Curve attribute. A Part.Line (as well as Part.Circle, Part.Arc, Part.Ellipse or PArt.BSpline) does not create an Edge, but rather a base geometry on which an Edge will be created. This is because here we haven't created Edges yet. Note that we didn't need to create Vertices? We could immediately create Part.Lines from FreeCAD Vectors. Then we can create the two linear segments: We will start by creating a planar shape like this:įirst, let's create the four base points: V1 = FreeCAD.Vector(0,10,0) For example, let's try to create a volume like this: We can now try creating complex shapes from scratch, by constructing all their components one by one. And finally, you can join any number of Shapes of any types together, which is then called a Compound. When a Shell is fully closed (watertight), you can form a Solid from it. With one or more Faces, you form a Shell. With one or more closed Wires, you form a Face (the additional Wires become "holes" in the Face). With one or two vertices, you form an Edge (full circles have only one vertex). So to resume the whole diagram of Part Shapes: Everything starts with Vertices. We can always check what is the type of a shape: print(boxShape.ShapeType) As we can expect, the boxShape will have 8 vertices, while the edge will only have 2, which are both part of the list of 8. Or, for each edge, its start point and end point: for e in boxShape.Edges:Īs you see, if our boxShape has a "Vertexes" attribute, each Edge of the boxShape also has a "Vertexes" attribute. All of them are lists, that can contain any number of elements or be empty: print(boxShape.Vertexes)įor example, let's find the area of each face of our box shape above: for f in boxShape.Faces: All Part Shapes have the following attributes: Vertexes, Edges, Wires, Faces, Shells and Solids. The exact same components exist here and can be retrieved from Python. At the end of the chapter about traditional modeling with the Part Workbench we showed a list that explains how Part Shapes are constructed, and their different components (Vertices, edges, faces, etc). In next chapter we will have a deeper look at how those parametric objects are constructed.įor now, let's explore our Part Shapes more in detail. Only it takes a Part Shape, not a number. In fact, Shape is also a property, just like Height. Note how we handled myObj.Shape, see that it is done exactly like we did in the previous chapter, when we changed other properties of an object, such as box.Height = 5. We can now easily create a "generic" document object in the current document (make sure you have at least one new document open), and give it a box shape like we just made: boxShape = Part.makeBox(3,5,7) What we did here is calculate a shape manually. Parametric objects will also have properties such as Length and Width, and will recalculate their Shape on-the-fly, whenever one of the properties change. Think of a FreeCAD document object as a container, that will host a shape. In FreeCAD, objects and their geometry are independent. It is not a FreeCAD document object (yet). This is where an important concept takes place. When you press Enter after typing the line above, nothing will appear in the 3D view, but something like this will be printed on the Python Console: which will instantly build an object for you. The Part module offers several convenience functions such as makeBox, makeCircle, etc. and browsing through the different methods offered there. Take a minute to explore the contents of the Part module, by typing Part. So the first thing we need to do to work with Part geometry, is to do the Python equivalent of switching to the Part Workbench: import the Part module: In fact, may other workbenches, such as Draft or Arch, do exactly what we will do in this chapter: They use Python code to create and manipulate Part geometry. We also saw that the big majority of the FreeCAD workbenches depend on a very fundamental one: the Part Workbench. The same concepts applies when working from Python code. In the previous chapters, we learned about the different workbenches of FreeCAD, and that each of them implements its own tools and geometry types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |