View Issue Details

IDProjectCategoryView StatusLast Update
0001376DraftFeaturepublic2014-03-23 20:49
Reporterulrich1a Assigned Toyorik  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformall 
Product Versiontrunk 
Summary0001376: Draft projection: Using a direction should give the same projection in Drawing and Draft-Workbench
DescriptionI want to combine Draft-Dimensions with Drawing-projections. This works only in special cases. At using any other projection direction then pure z or x or y, both projections are not in sync.
I modified in WorkingPlane.py the function:
 def alignToPointAndAxis(self, point, axis, offset, upvec=None):
in order to get the same projection from the Draft and the Drawing workbench.
See this post: http://forum.freecadweb.org/viewtopic.php?f=3&t=5392#p44617
The function is also used in other Workbenches (Arch). I have not enough knowledge to do the right tests, in order to check if this will give problems or not.
Having the same projection in all cases, makes dimensioned drawings much easier.
Additional InformationOS: Debian GNU/Linux 7.3 (wheezy)
Platform: 32-bit
Version: 0.14.3069 (Git)
Branch: master
Hash: a7d297c33d6b3f8a1758413eae192304a4f2c208
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
TagsNo tags attached.
FreeCAD Information

Activities

ulrich1a

2014-02-09 22:52

reporter   ~0004177

I got some working code. I posted it here: http://forum.freecadweb.org/viewtopic.php?f=3&t=5392&start=10#p45651

Ulrich

ulrich1a

2014-02-12 21:29

reporter   ~0004202

Yorik did you have a look at the code in the post above? This is a version that solves the problems. It calculates the same u and v vectors as the occ-code on the fly.

Ulrich

yorik

2014-03-08 20:36

administrator   ~0004397

I have a very hard time figuring out where your code differs from the current code... Can you post a diff?

ulrich1a

2014-03-18 19:41

reporter  

0001-Makes-Draft-Drawing-Projection-in-sync-with-Drawing-.patch (4,306 bytes)   
From a1d9268cebc38f7b9906193daca8a2d573733d1c Mon Sep 17 00:00:00 2001
From: Ulrich Brammer <ubrammer@t-online.de>
Date: Tue, 18 Mar 2014 19:37:39 +0100
Subject: Makes Draft-Drawing-Projection in sync with Drawing-Projection

---
 src/Mod/Draft/Draft.py        |    2 +-
 src/Mod/Draft/WorkingPlane.py |   58 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py
index 8bd7c60..2c7c98e 100644
--- a/src/Mod/Draft/Draft.py
+++ b/src/Mod/Draft/Draft.py
@@ -1549,7 +1549,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
         if isinstance(direction,FreeCAD.Vector):
             if direction != Vector(0,0,0):
                 plane = WorkingPlane.plane()
-                plane.alignToPointAndAxis(Vector(0,0,0),direction.negative(),0)
+                plane.alignToPointAndAxis_SVG(Vector(0,0,0),direction.negative().negative(),0)
         elif isinstance(direction,WorkingPlane.plane):
             plane = direction
 
diff --git a/src/Mod/Draft/WorkingPlane.py b/src/Mod/Draft/WorkingPlane.py
index 25a0c3f..69207bd 100644
--- a/src/Mod/Draft/WorkingPlane.py
+++ b/src/Mod/Draft/WorkingPlane.py
@@ -136,6 +136,64 @@ class plane:
         # FreeCAD.Console.PrintMessage("(position = " + str(self.position) + ")\n")
         # FreeCAD.Console.PrintMessage("Current workplane: x="+str(DraftVecUtils.rounded(self.u))+" y="+str(DraftVecUtils.rounded(self.v))+" z="+str(DraftVecUtils.rounded(self.axis))+"\n")
 
+    def alignToPointAndAxis_SVG(self, point, axis, offset):
+        # based on cases table
+        self.doc = FreeCAD.ActiveDocument
+        self.axis = axis;
+        self.axis.normalize()
+        ref_vec = Vector(0.0, 1.0, 0.0)
+
+        if ((abs(axis.x) > abs(axis.y)) and (abs(axis.y) > abs(axis.z))):
+            ref_vec = Vector(0.0, 0., 1.0)
+            self.u = axis.negative().cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "Case new"
+        
+        elif ((abs(axis.y) > abs(axis.z)) and (abs(axis.z) >= abs(axis.x))):
+            ref_vec = Vector(1.0, 0.0, 0.0)
+            self.u = axis.negative().cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "Y>Z, View Y"
+
+        elif ((abs(axis.y) >= abs(axis.x)) and (abs(axis.x) > abs(axis.z))):
+            ref_vec = Vector(0.0, 0., 1.0)
+            self.u = axis.cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "ehem. XY, Case XY"
+
+        elif ((abs(axis.x) > abs(axis.z)) and (abs(axis.z) >= abs(axis.y))):
+            self.u = axis.cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "X>Z, View X"
+
+        elif ((abs(axis.z) >= abs(axis.y)) and (abs(axis.y) > abs(axis.x))):
+            ref_vec = Vector(1.0, 0., 0.0)
+            self.u = axis.cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "Y>X, Case YZ"
+
+        else:
+            self.u = axis.negative().cross(ref_vec)
+            self.u.normalize()
+            self.v = DraftVecUtils.rotate(self.u, math.pi/2, self.axis)
+            #projcase = "else"
+
+        #spat_vec = self.u.cross(self.v)
+        #spat_res = spat_vec.dot(axis)
+        #FreeCAD.Console.PrintMessage(projcase + " spat Prod = " + str(spat_res) + "\n")
+        
+        offsetVector = Vector(axis); offsetVector.multiply(offset)
+        self.position = point.add(offsetVector)
+        self.weak = False
+        # FreeCAD.Console.PrintMessage("(position = " + str(self.position) + ")\n")
+        # FreeCAD.Console.PrintMessage("Current workplane: x="+str(DraftVecUtils.rounded(self.u))+" y="+str(DraftVecUtils.rounded(self.v))+" z="+str(DraftVecUtils.rounded(self.axis))+"\n")
+
+
     def alignToCurve(self, shape, offset):
         if shape.ShapeType == 'Edge':
             #??? TODO: process curve here.  look at shape.edges[0].Curve
-- 
1.7.10.4

ulrich1a

2014-03-18 19:43

reporter   ~0004476

I did upload a patch to this Feature-request.

Ulrich

yorik

2014-03-23 20:27

administrator   ~0004485

Okay i just tested and merged your patch, there are still inversions compared to the Drawing module projection direction, but the correct placement on the sheet is already a big improvement. Thanks!

Related Changesets

FreeCAD: master e293d61d

2014-03-23 21:28:17

yorik

Details Diff
Draft: Added Ulrichs patch to fix Draft-Drawing projections - fixes 0001376 Affected Issues
0001376
mod - src/Mod/Draft/Draft.py Diff File
mod - src/Mod/Draft/WorkingPlane.py Diff File

Issue History

Date Modified Username Field Change
2014-01-30 21:27 ulrich1a New Issue
2014-02-04 11:16 yorik Assigned To => yorik
2014-02-04 11:16 yorik Status new => assigned
2014-02-04 15:09 yorik Project FreeCAD => Draft
2014-02-09 22:52 ulrich1a Note Added: 0004177
2014-02-12 21:29 ulrich1a Note Added: 0004202
2014-03-08 20:36 yorik Note Added: 0004397
2014-03-08 20:37 yorik Severity major => minor
2014-03-18 19:41 ulrich1a File Added: 0001-Makes-Draft-Drawing-Projection-in-sync-with-Drawing-.patch
2014-03-18 19:43 ulrich1a Note Added: 0004476
2014-03-23 20:27 yorik Note Added: 0004485
2014-03-23 20:49 yorik Changeset attached => FreeCAD Master master e293d61d
2014-03-23 20:49 yorik Status assigned => closed
2014-03-23 20:49 yorik Resolution open => fixed