FreeCAD

Форк
0
64 строки · 3.6 Кб
1
# ***************************************************************************
2
# *   Copyright (c) 2014 Juergen Riegel <FreeCAD@juergen-riegel.net>        *
3
# *                                                                         *
4
# *   This program is free software; you can redistribute it and/or modify  *
5
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
6
# *   as published by the Free Software Foundation; either version 2 of     *
7
# *   the License, or (at your option) any later version.                   *
8
# *   for detail see the LICENCE text file.                                 *
9
# *                                                                         *
10
# *   This program is distributed in the hope that it will be useful,       *
11
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
# *   GNU Library General Public License for more details.                  *
14
# *                                                                         *
15
# *   You should have received a copy of the GNU Library General Public     *
16
# *   License along with this program; if not, write to the Free Software   *
17
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
18
# *   USA                                                                   *
19
# *                                                                         *
20
# ***************************************************************************
21

22
import FreeCAD, FreeCADGui, Sketcher, Part
23

24

25
__title__ = "Hexagon profile lib"
26
__author__ = "Juergen Riegel"
27
__url__ = "https://www.freecad.org"
28

29
App = FreeCAD
30
Gui = FreeCADGui
31

32

33
def makeHexagonSimple(sketchName=None):
34
    if not sketchName:
35
        sketch = App.ActiveDocument.addObject("Sketcher::SketchObject", "Hexagon")
36
    else:
37
        sketch = App.ActiveDocument.getObject(sketchName)
38

39
    geoList = []
40
    geoList.append(Part.LineSegment(App.Vector(-20.00, 34.64, 0), App.Vector(20.00, 34.64, 0)))
41
    geoList.append(Part.LineSegment(App.Vector(20.00, 34.64, 0), App.Vector(47.082363, 0.00, 0)))
42
    geoList.append(Part.LineSegment(App.Vector(40.00, 0.00, 0), App.Vector(20.00, -34.64, 0)))
43
    geoList.append(Part.LineSegment(App.Vector(20.00, -34.64, 0), App.Vector(-20.00, -34.64, 0)))
44
    geoList.append(Part.LineSegment(App.Vector(-20.00, -34.64, 0), App.Vector(-40.00, 0.00, 0)))
45
    geoList.append(Part.LineSegment(App.Vector(-40.00, 0.00, 0), App.Vector(-20.00, 34.64, 0)))
46
    (l1, l2, l3, l4, l5, l6) = sketch.addGeometry(geoList)
47

48
    conList = []
49
    conList.append(Sketcher.Constraint("Coincident", l1, 2, l2, 1))
50
    conList.append(Sketcher.Constraint("Coincident", l2, 2, l3, 1))
51
    conList.append(Sketcher.Constraint("Coincident", l3, 2, l4, 1))
52
    conList.append(Sketcher.Constraint("Coincident", l4, 2, l5, 1))
53
    conList.append(Sketcher.Constraint("Coincident", l5, 2, l6, 1))
54
    conList.append(Sketcher.Constraint("Coincident", l6, 2, l1, 1))
55
    conList.append(Sketcher.Constraint("Equal", l1, l2))
56
    conList.append(Sketcher.Constraint("Equal", l2, l3))
57
    conList.append(Sketcher.Constraint("Equal", l3, l4))
58
    conList.append(Sketcher.Constraint("Equal", l4, l5))
59
    conList.append(Sketcher.Constraint("Equal", l5, l6))
60
    conList.append(Sketcher.Constraint("Angle", l1, 2, l2, 1, App.Units.Quantity("120.000000 deg")))
61
    conList.append(Sketcher.Constraint("Angle", l3, 2, l4, 1, App.Units.Quantity("120.000000 deg")))
62
    conList.append(Sketcher.Constraint("Angle", l5, 2, l6, 1, App.Units.Quantity("120.000000 deg")))
63
    sketch.addConstraint(conList)
64
    return
65

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.