FreeCAD

Форк
0
/
CommandSolveAssembly.py 
76 строк · 2.9 Кб
1
# SPDX-License-Identifier: LGPL-2.1-or-later
2
# /**************************************************************************
3
#                                                                           *
4
#    Copyright (c) 2023 Ondsel <development@ondsel.com>                     *
5
#                                                                           *
6
#    This file is part of FreeCAD.                                          *
7
#                                                                           *
8
#    FreeCAD is free software: you can redistribute it and/or modify it     *
9
#    under the terms of the GNU Lesser General Public License as            *
10
#    published by the Free Software Foundation, either version 2.1 of the   *
11
#    License, or (at your option) any later version.                        *
12
#                                                                           *
13
#    FreeCAD is distributed in the hope that it will be useful, but         *
14
#    WITHOUT ANY WARRANTY; without even the implied warranty of             *
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU       *
16
#    Lesser General Public License for more details.                        *
17
#                                                                           *
18
#    You should have received a copy of the GNU Lesser General Public       *
19
#    License along with FreeCAD. If not, see                                *
20
#    <https://www.gnu.org/licenses/>.                                       *
21
#                                                                           *
22
# **************************************************************************/
23

24
import os
25
import FreeCAD as App
26

27
from PySide.QtCore import QT_TRANSLATE_NOOP
28

29
if App.GuiUp:
30
    import FreeCADGui as Gui
31
    from PySide import QtCore, QtGui, QtWidgets
32

33
import UtilsAssembly
34
import Assembly_rc
35

36
# translate = App.Qt.translate
37

38
__title__ = "Assembly Command to Solve Assembly"
39
__author__ = "Ondsel"
40
__url__ = "https://www.freecad.org"
41

42

43
class CommandSolveAssembly:
44
    def __init__(self):
45
        pass
46

47
    def GetResources(self):
48

49
        return {
50
            "Pixmap": "Assembly_SolveAssembly",
51
            "MenuText": QT_TRANSLATE_NOOP("Assembly_SolveAssembly", "Solve Assembly"),
52
            "Accel": "Z",
53
            "ToolTip": "<p>"
54
            + QT_TRANSLATE_NOOP(
55
                "Assembly_SolveAssembly",
56
                "Solve the currently active assembly.",
57
            )
58
            + "</p>",
59
            "CmdType": "ForEdit",
60
        }
61

62
    def IsActive(self):
63
        return UtilsAssembly.isAssemblyCommandActive() and UtilsAssembly.isAssemblyGrounded()
64

65
    def Activated(self):
66
        assembly = UtilsAssembly.activeAssembly()
67
        if not assembly:
68
            return
69

70
        App.setActiveTransaction("Solve assembly")
71
        assembly.solve()
72
        App.closeActiveTransaction()
73

74

75
if App.GuiUp:
76
    Gui.addCommand("Assembly_SolveAssembly", CommandSolveAssembly())
77

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

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

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

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