FreeCAD-macros
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
44import FreeCAD as App
45import TechDraw
46
47def TechDrawMigrateFromv018():
48increment = App.Units.Quantity(270, App.Units.Unit("deg"))
49for obj in App.ActiveDocument.Objects:
50if obj.isDerivedFrom("TechDraw::DrawViewSection"):
51if obj.Rotation != 0.0:
52obj.Rotation = obj.Rotation + increment
53obj.touch()
54for inObj in obj.InList:
55if obj.isDerivedFrom("TechDraw::DrawViewDimension"):
56inObj.touch()
57elif obj.isDerivedFrom("TechDraw::DrawViewPart"):
58if obj.Rotation != 0.0:
59obj.Rotation = -obj.Rotation
60obj.touch()
61
62
63if __name__ == '__main__':
64TechDrawMigrateFromv018()
65App.ActiveDocument.recompute()
66
67