Draft: added ConvertDraftSketches() convenience function to convert App::Annotations to the new Draft Text object

This commit is contained in:
Yorik van Havre
2018-05-16 16:27:12 -03:00
parent 8ea89a40e0
commit 8da0c7050d

View File

@@ -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)
## @}