From b6599c5315ba557371dbdacca0b9cf35f5b7f7f2 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Sun, 15 Sep 2024 10:32:15 +0200 Subject: [PATCH] Draft: Fix regression with layer print color Problem with the same cause as #16212. --- src/Mod/Draft/draftfunctions/svg.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py index 11896b34ae..93571f71a1 100644 --- a/src/Mod/Draft/draftfunctions/svg.py +++ b/src/Mod/Draft/draftfunctions/svg.py @@ -904,14 +904,26 @@ def get_svg(obj, return svg +# Similar function as in view_layer.py +def _get_layer(obj): + """Get the layer the object belongs to.""" + finds = obj.Document.findObjects(Name="LayerContainer") + if not finds: + return None + for layer in finds[0].Group: + if utils.get_type(layer) == "Layer" and obj in layer.Group: + return layer + return None + + def get_print_color(obj): - """returns the print color of the parent layer, if available""" - for parent in obj.InListRecursive: - if (hasattr(parent,"ViewObject") - and hasattr(parent.ViewObject,"UsePrintColor") - and parent.ViewObject.UsePrintColor): - if hasattr(parent.ViewObject,"LinePrintColor"): - return parent.ViewObject.LinePrintColor + """Return the print color of the parent layer, if available.""" + # Layers are not in the Inlist of obj because a layer's Group is App::PropertyLinkListHidden: + layer = _get_layer(obj) + if layer is None: + return None + if layer.ViewObject.UsePrintColor: + return layer.ViewObject.LinePrintColor return None