diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 1038f697f6..ece7a9db7a 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -2,6 +2,7 @@ # *************************************************************************** # * Copyright (c) 2009, 2010 Yorik van Havre * # * Copyright (c) 2009, 2010 Ken Cline * +# * Copyright (c) 2020 FreeCAD Developers * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * @@ -69,6 +70,7 @@ __author__ = ("Yorik van Havre, Werner Mayer, Martin Burbaum, Ken Cline, " "Dmitry Chigrin, Daniel Falck") __url__ = "https://www.freecadweb.org" + # --------------------------------------------------------------------------- # Backwards compatibility # --------------------------------------------------------------------------- @@ -76,6 +78,9 @@ from DraftLayer import Layer as _VisGroup from DraftLayer import ViewProviderLayer as _ViewProviderVisGroup from DraftLayer import makeLayer +from draftutils.utils import convert_draft_texts +from draftutils.utils import convertDraftTexts + # --------------------------------------------------------------------------- # General functions # --------------------------------------------------------------------------- @@ -183,6 +188,7 @@ from draftutils.gui_utils import select from draftutils.gui_utils import loadTexture from draftutils.gui_utils import load_texture + #--------------------------------------------------------------------------- # Draft functions #--------------------------------------------------------------------------- @@ -229,6 +235,7 @@ from draftfunctions.mirror import mirror from draftfunctions.upgrade import upgrade + #--------------------------------------------------------------------------- # Draft objects #--------------------------------------------------------------------------- @@ -404,33 +411,4 @@ if gui: from draftviewproviders.view_text import ViewProviderText ViewProviderDraftText = ViewProviderText -def convertDraftTexts(textslist=[]): - """ - converts the given Draft texts (or all that is found - in the active document) to the new object - This function was already present at splitting time during v 0.19 - """ - if not isinstance(textslist,list): - textslist = [textslist] - if not textslist: - for o in FreeCAD.ActiveDocument.Objects: - if o.TypeId == "App::Annotation": - textslist.append(o) - todelete = [] - for o in textslist: - l = o.Label - o.Label = l+".old" - obj = makeText(o.LabelText,point=o.Position) - obj.Label = l - todelete.append(o.Name) - for p in o.InList: - if p.isDerivedFrom("App::DocumentObjectGroup"): - if o in p.Group: - g = p.Group - g.append(obj) - p.Group = g - for n in todelete: - FreeCAD.ActiveDocument.removeObject(n) - - ## @} diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index b6fbb86c1d..2b30d3f5e9 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -1109,6 +1109,38 @@ def is_closed_edge(edge_index, object): isClosedEdge = is_closed_edge +def convert_draft_texts(textslist=[]): + """ + converts the given Draft texts (or all that is found + in the active document) to the new object + This function was already present at splitting time during v 0.19 + """ + if not isinstance(textslist,list): + textslist = [textslist] + if not textslist: + for o in FreeCAD.ActiveDocument.Objects: + if o.TypeId == "App::Annotation": + textslist.append(o) + todelete = [] + for o in textslist: + l = o.Label + o.Label = l+".old" + obj = makeText(o.LabelText,point=o.Position) + obj.Label = l + todelete.append(o.Name) + for p in o.InList: + if p.isDerivedFrom("App::DocumentObjectGroup"): + if o in p.Group: + g = p.Group + g.append(obj) + p.Group = g + for n in todelete: + FreeCAD.ActiveDocument.removeObject(n) + + +convertDraftTexts = convert_draft_texts + + def utf8_decode(text): r"""Decode the input string and return a unicode string.