From 1843f896593a6b946ed7dcf60c186630b7914321 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sun, 28 Aug 2016 14:18:12 -0300 Subject: [PATCH] Draft: fixed export of invalid shapes to DXF --- src/Mod/Draft/importDXF.py | 45 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 211c4e1f0..736beb956 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -1815,10 +1815,12 @@ def export(objectslist,filename,nospline=False,lwPoly=False): for ob in exportList: print("processing "+str(ob.Name)) if ob.isDerivedFrom("Part::Feature"): - if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("dxfmesh"): - sh = None - if not ob.Shape.isNull(): - writeMesh(ob,dxf) + sh = None + if ob.Shape.isNull(): + print ("Null shape - skipping") + continue + elif FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("dxfmesh"): + writeMesh(ob,dxf) elif gui and FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetBool("dxfproject"): direction = FreeCADGui.ActiveDocument.ActiveView.\ getViewDirection().multiply(-1) @@ -1829,29 +1831,28 @@ def export(objectslist,filename,nospline=False,lwPoly=False): else: sh = ob.Shape if sh: - if not sh.isNull(): - if sh.ShapeType == 'Compound': - if (len(sh.Wires) == 1): - # only one wire in this compound, no lone edge -> polyline - if (len(sh.Wires[0].Edges) == len(sh.Edges)): - writeShape(sh,ob,dxf,nospline,lwPoly) - else: - # 1 wire + lone edges -> block - block = getBlock(sh,ob,lwPoly) - dxf.blocks.append(block) - dxf.append(dxfLibrary.Insert(name=ob.Name.upper(), - color=getACI(ob), - layer=getGroup(ob))) + if sh.ShapeType == 'Compound': + if (len(sh.Wires) == 1): + # only one wire in this compound, no lone edge -> polyline + if (len(sh.Wires[0].Edges) == len(sh.Edges)): + writeShape(sh,ob,dxf,nospline,lwPoly) else: - # all other cases: block + # 1 wire + lone edges -> block block = getBlock(sh,ob,lwPoly) dxf.blocks.append(block) dxf.append(dxfLibrary.Insert(name=ob.Name.upper(), - color=getACI(ob), - layer=getGroup(ob))) - + color=getACI(ob), + layer=getGroup(ob))) else: - writeShape(sh,ob,dxf,nospline,lwPoly) + # all other cases: block + block = getBlock(sh,ob,lwPoly) + dxf.blocks.append(block) + dxf.append(dxfLibrary.Insert(name=ob.Name.upper(), + color=getACI(ob), + layer=getGroup(ob))) + + else: + writeShape(sh,ob,dxf,nospline,lwPoly) elif Draft.getType(ob) == "Annotation": # texts