From f1e86b3e11050ad475b95be0aff8f25d77e0c389 Mon Sep 17 00:00:00 2001 From: furti Date: Fri, 8 Feb 2019 18:38:18 +0100 Subject: [PATCH] Fix missing DWG imports in ArchSectionPlane.getSVG When a DWG file is imported into FreeCAD it gets imported as a Part object with a compound shape. One would imagine, that such an object should be rendered like a symbol inside a TechDraw View. But when the imported shape is inside a SectionPlane that also contains solids, the shape is not included in the SVG. The problem is, that getCutShapes only uses solid shapes, when a volume was cut before. But the imported DWG is a flat 2D object and has no solids inside. To fix it, the getSVG method will check if an object looks like a draft object, meaning: - It has a shape - It has no solids - It has no volume When it finds such a shape, it will treat it like a draft object. So it is displayed like a symbol in the resulting SVG. https://forum.freecadweb.org/viewtopic.php?f=3&t=34079 --- src/Mod/Arch/ArchSectionPlane.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 61084b6b48..76ce16742a 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -95,6 +95,18 @@ def makeSectionView(section,name="View"): view.Label = translate("Arch","View of")+" "+section.Name return view +def looksLikeDraft(o): + # If there is no shape at all ignore it + if not hasattr(o, 'Shape') or o.Shape.isNull(): + return False + + # If there are solids in the object, it will be handled later + # by getCutShapes + if len(o.Shape.Solids) > 0: + return False + + # If we have a shape, but no volume, it looks like a flat 2D object + return o.Shape.Volume == 0 def getCutShapes(objs,section,showHidden): @@ -178,6 +190,8 @@ def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale drafts.append(o) elif o.isDerivedFrom("Part::Part2DObject"): drafts.append(o) + elif looksLikeDraft(o): + drafts.append(o) else: nonspaces.append(o) if Draft.getType(o) == "Window":