View Issue Details

IDProjectCategoryView StatusLast Update
0001964DraftPatchpublic2015-02-12 14:19
Reporterswill Assigned Toyorik  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSUbuntu ServerOS Version14.04 
Summary0001964: importSVG export fails without GUI
DescriptionWhen trying to export an SVG file on Ubuntu 14.04 Server without X installed I get the following error:

Traceback (most recent call last):
  File "./custom.py", line 153, in <module>
    importSVG.export(FreeCAD.ActiveDocument.Objects, "%s/custom.svg" % (config['app']['export']))
  File "/usr/lib/freecad/Mod/Draft/importSVG.py", line 1207, in export
    svg.write(Draft.getSVG(ob))
  File "/usr/lib/freecad/Mod/Draft/Draft.py", line 2159, in getSVG
    (obj.Name,i))
  File "/usr/lib/freecad/Mod/Draft/Draft.py", line 1802, in getPath
    drawing_plane_normal = FreeCAD.DraftWorkingPlane.axis
AttributeError: 'module' object has no attribute 'DraftWorkingPlane'

This issue is the FreeCAD attribute 'DraftWorkingPlane' is used without checking that it actually exists. Everywhere else in the Draft.py code there is a check before using it and it defaults to the Z axis if it does not exist.

I have created a patch for this issue following the same form as the other examples in the same file. I have tested this fix and it works.

Cheers and thanks for all the hard work. :)
TagsNo tags attached.
FreeCAD Information

Activities

swill

2015-02-12 04:52

reporter  

0001-Checking-FreeCAD.DraftWorkingPlane.axis-before-using.patch (1,244 bytes)   
From f24f1dcde7f36d5cd03f1ae17524f5f1a27c2c4e Mon Sep 17 00:00:00 2001
From: Will Stevens <wstevens@cloudops.com>
Date: Wed, 11 Feb 2015 23:41:14 -0500
Subject: [PATCH] Checking 'FreeCAD.DraftWorkingPlane.axis' before using it

---
 src/Mod/Draft/Draft.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py
index 800af91..68cb516 100644
--- a/src/Mod/Draft/Draft.py
+++ b/src/Mod/Draft/Draft.py
@@ -1799,7 +1799,10 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
                         if rot < -90:
                             rot += 180
                         #be carefull with the sweep flag
-                    drawing_plane_normal = FreeCAD.DraftWorkingPlane.axis
+                    if hasattr(FreeCAD,"DraftWorkingPlane"):
+                        drawing_plane_normal = FreeCAD.DraftWorkingPlane.axis
+                    else:
+                        drawing_plane_normal = FreeCAD.Vector(0,0,1)
                     if plane: drawing_plane_normal = plane.axis
                     flag_large_arc = (((e.ParameterRange[1] - \
                             e.ParameterRange[0]) / math.pi) % 2) > 1
-- 
1.9.3 (Apple Git-50)

yorik

2015-02-12 13:59

administrator   ~0005790

Added the patch, thanks!

Related Changesets

FreeCAD: master cd5783ac

2015-02-12 14:57:39

yorik

Details Diff
Draft: fixed importSVG - fixes 0001964 Affected Issues
0001964
mod - src/Mod/Draft/Draft.py Diff File

Issue History

Date Modified Username Field Change
2015-02-12 04:52 swill New Issue
2015-02-12 04:52 swill File Added: 0001-Checking-FreeCAD.DraftWorkingPlane.axis-before-using.patch
2015-02-12 13:59 yorik Note Added: 0005790
2015-02-12 14:19 yorik Changeset attached => FreeCAD Master master cd5783ac
2015-02-12 14:19 yorik Assigned To => yorik
2015-02-12 14:19 yorik Status new => closed
2015-02-12 14:19 yorik Resolution open => fixed