From f7db685a2821adaf23c85a25855401ecc1eeff2c Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sun, 15 Jan 2023 00:20:34 +0100 Subject: [PATCH] Draft: gui_setstyle.py onApplyAnnot should check for doc (#8196) --- src/Mod/Draft/draftguitools/gui_setstyle.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_setstyle.py b/src/Mod/Draft/draftguitools/gui_setstyle.py index 50f52c2442..f42285c587 100644 --- a/src/Mod/Draft/draftguitools/gui_setstyle.py +++ b/src/Mod/Draft/draftguitools/gui_setstyle.py @@ -195,14 +195,17 @@ class Draft_SetStyle_TaskPanel: def onApplyAnnot(self): - from draftutils import utils - objs = FreeCAD.ActiveDocument.Objects - typs = ["Dimension", "LinearDimension", "AngularDimension", "Text", "DraftText", "Label"] - for obj in objs: - if utils.get_type(obj) in typs: - self.apply_style_to_obj(obj) + if FreeCAD.ActiveDocument is not None: # Command can be called without a document. + from draftutils import utils + objs = FreeCAD.ActiveDocument.Objects + typs = ["Dimension", "LinearDimension", "AngularDimension", + "Text", "DraftText", "Label"] + for obj in objs: + if utils.get_type(obj) in typs: + self.apply_style_to_obj(obj) def apply_style_to_obj(self, obj): + vobj = obj.ViewObject if not vobj: return