FreeCAD-macros

Форк
0
/
TechDrawMigrateFromv018.FCMacro 
65 строк · 2.9 Кб
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3

4
# ***************************************************************************
5
# *                                                                         *
6
# *   Copyright (c) 2022 - Wanderer Fan <wandererfan@gmail.com>             *
7
# *                                                                         *
8
# *   This program is free software; you can redistribute it and/or modify  *
9
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
10
# *   as published by the Free Software Foundation; either version 2 of     *
11
# *   the License, or (at your option) any later version.                   *
12
# *   for detail see the LICENCE text file.                                 *
13
# *                                                                         *
14
# *   This program is distributed in the hope that it will be useful,       *
15
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
16
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
17
# *   GNU Library General Public License for more details.                  *
18
# *                                                                         *
19
# *   You should have received a copy of the GNU Library General Public     *
20
# *   License along with this program; if not, write to the Free Software   *
21
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
22
# *   USA                                                                   *
23
# *                                                                         *
24
# ***************************************************************************
25
"""Migrates drawings made in FreeCAD v0.18 to v0.19."""
26

27
__Name__ = 'TechDrawMigrateFromv018'
28
__Comment__ = 'Convert v018 Rotation property to v019'
29
__Author__ = 'WandererFan'
30
__Version__ = '0.1.0'
31
__License__ = 'CC-BY-3.0'
32
__Web__ = 'http://www.freecadweb.org/'
33
__Wiki__ = 'http://www.freecadweb.org/wiki/Macro_TechDrawViewSet'
34
__Icon__ = ''
35
__Help__ = 'Open a v018 file in v019, execute'
36
__Status__ = 'Alpha'
37
__Requires__ = ''
38
__Communication__ = 'https://github.com/FreeCAD/FreeCAD-macros/issues/'
39
__Files__ = ''
40

41

42
# convert v0.18 Rotation values to v0.19 
43

44
import FreeCAD as App
45
import TechDraw
46

47
def TechDrawMigrateFromv018():
48
    increment = App.Units.Quantity(270, App.Units.Unit("deg"))
49
    for obj in App.ActiveDocument.Objects:
50
        if obj.isDerivedFrom("TechDraw::DrawViewSection"):
51
            if obj.Rotation != 0.0:
52
                obj.Rotation = obj.Rotation + increment
53
                obj.touch()
54
            for inObj in obj.InList:
55
                if obj.isDerivedFrom("TechDraw::DrawViewDimension"):
56
                    inObj.touch()
57
        elif obj.isDerivedFrom("TechDraw::DrawViewPart"):
58
            if obj.Rotation != 0.0:
59
                obj.Rotation = -obj.Rotation
60
                obj.touch()
61

62

63
if __name__ == '__main__':
64
    TechDrawMigrateFromv018()
65
    App.ActiveDocument.recompute()
66

67

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

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

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

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