From 8da0c7050d7466aaa8e30c7d072148bd63fa1782 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 16 May 2018 16:27:12 -0300 Subject: [PATCH] Draft: added ConvertDraftSketches() convenience function to convert App::Annotations to the new Draft Text object --- src/Mod/Draft/Draft.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index a650fbbe72..2e321b9ec3 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -7171,4 +7171,28 @@ class ViewProviderDraftText: return None +def convertDraftTexts(textslist=[]): + "converts the given Draft texts (or all that are found in the active document) to the new object" + 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) + ## @}