FreeCAD-macros

Форк
0
/
TechDrawAnnoTextFromv018.FCMacro 
65 строк · 3.2 Кб
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 Annotation Text made in FreeCAD v0.18 to v0.19."""
26

27
__Name__ = 'TechDrawAnnoTextFromv018'
28
__Comment__ = 'Convert v018 Annotation Text size 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_TechDrawAnnoTextFromv018'
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
# font sizes were once set using QFont.setPointSize but are now set using QFont.setPixelSize.
42
# text set the old way will be bigger than text set the new way since points are bigger than
43
# pixels.  This macro adjusts the text size in old files to give approximately the same size
44
# result.
45

46
import FreeCAD as App
47
import TechDraw
48

49
def TechDrawAnnoTextFromv018():
50
    factor = 96.0/72.0    # pixels/inch vs points/inch
51
    for obj in App.ActiveDocument.Objects:
52
        if obj.isDerivedFrom("TechDraw::DrawViewAnnotation"):
53
            oldSize = obj.TextSize
54
            obj.TextSize = oldSize * factor
55
        if obj.isDerivedFrom("TechDraw::DrawViewDimension"):
56
            oldSize = obj.ViewObject.Fontsize
57
            obj.ViewObject.Fontsize = oldSize * factor
58
        if obj.isDerivedFrom("TechDraw::DrawViewBalloon"):
59
            oldSize = obj.ViewObject.Fontsize
60
            obj.ViewObject.Fontsize = oldSize * factor
61

62

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

67

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

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

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

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