From 2a60d81c7d6228fa621910c0a711f3b73a00e0b5 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 9 May 2021 17:19:05 +0200 Subject: [PATCH 1/2] Arch: Do not draw draft-like groups twice in section view When drawing a section view, first a list of objects to draw is made. Starting with the objects selected by the section plane, any groups or group-like objects are recursively expanded. The resulting list contains all contained objects, but also the expanded groups themselves (due to Draft.get_group_contents with addgroups set). This list of objects is then further categorized and processed. In this categorization, there was already an exception for DocumentObjectGroup instances, which were omitted from the resulting `nonspaces` list (presumably since there is no point in drawing the groups themselves when their contents are already in the list). However, any groups that only contain flat objects would be caught by `looksLikeDraf()` and added to the `drafts` list, before this exception could ignore them. This causes these groups to be processed by Draft.get_svg, which does so by calling itself recursively on the group contents. Effectively, this means that the contents of such groups is drawn on the section view twice. Even more, since Draft.get_svg does not do a visibility check like Arch.getSVG does, this causes invisible objects to show up when not intended. This commit fixes this by moving the DocumentObjectGroup exception a bit further up, so all these objects should be dropped. An alternative fix might be to pass addgroups=False to Draft.get_group_contents (in getSectionData), but that also prevents group-like objects (Building, BuildingPart, Space, Site) from being returned, but those likely need to be returned so they can be sectioned if needed (though if just spaces are needed, then Draft.get_group_contents also have a spaces argument to return just those). --- src/Mod/Arch/ArchSectionPlane.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 440bdd0405..86c376635e 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -375,9 +375,12 @@ def getSVG(source, drafts.append(o) elif o.isDerivedFrom("Part::Part2DObject"): drafts.append(o) + elif o.isDerivedFrom("App::DocumentObjectGroup"): + # These will have been expanded by getSectionData already + pass elif looksLikeDraft(o): drafts.append(o) - elif not o.isDerivedFrom("App::DocumentObjectGroup"): + else: nonspaces.append(o) if Draft.getType(o.getLinkedObject()) == "Window": # To support Link of Windows(Doors) windows.append(o) From ffbac23432ea2337bcfd85689911a7ddb5ace0a3 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 9 May 2021 17:33:46 +0200 Subject: [PATCH 2/2] Draft: Improve docs for get_group_contents spaces parameter The documentation suggested subtly different semantics from what the code implements. --- src/Mod/Draft/draftutils/groups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftutils/groups.py b/src/Mod/Draft/draftutils/groups.py index d8fd3761ac..c1557fb552 100644 --- a/src/Mod/Draft/draftutils/groups.py +++ b/src/Mod/Draft/draftutils/groups.py @@ -197,8 +197,8 @@ def get_group_contents(objectslist, spaces: bool, optional It defaults to `False`. - If it is `True`, Arch Spaces are treated as groups, - and are added to the output list. + If it is `True`, Arch Spaces are added to the output list even + when addgroups is False (their contents are always added). noarchchild: bool, optional It defaults to `False`.