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
This commit is contained in:
furti
2019-02-08 18:38:18 +01:00
committed by Yorik van Havre
parent 3cc1a327ce
commit f1e86b3e11

View File

@@ -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":