aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-05-31 00:38:01 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-05-31 00:38:01 +0200
commitea5904139f80cb96400febcfb289a8fd4729da2c (patch)
treee233543124f33eb8e772668068d55e64dd522502
parentfd1626b397afe407f68de99486af86beae9625be (diff)
downloadfreecad-boxer-ea5904139f80cb96400febcfb289a8fd4729da2c.tar.gz
freecad-boxer-ea5904139f80cb96400febcfb289a8fd4729da2c.tar.bz2
freecad-boxer-ea5904139f80cb96400febcfb289a8fd4729da2c.tar.xz
freecad-boxer-ea5904139f80cb96400febcfb289a8fd4729da2c.zip
o Fixing rotation and alignment for non-cube shapes.
-rw-r--r--Boxer.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/Boxer.py b/Boxer.py
index c347049..facb4e3 100644
--- a/Boxer.py
+++ b/Boxer.py
@@ -1,7 +1,7 @@
# import Boxer; reload(Boxer); import BoxerGui as bg; reload(bg);
#import FreeCAD
-from FreeCAD import Base, Vector, Matrix
+from FreeCAD import Base, Vector, Matrix, Placement, Rotation
import Part
from enum import Enum
import math
@@ -232,12 +232,19 @@ def makeBox(doc, cfg):
sep = cfg.outerWidth * 0.05
def m(rotX, rotY, moveX, moveY, moveZ):
+ if rotX and rotY:
+ p = Placement(Vector(0, 0, 0), Rotation(Vector(1, 1, 1), 120))
+ m = p.toMatrix()
+ else:
+ m = Matrix()
+ if rotX:
+ m.rotateX(math.radians(90))
+ if rotY:
+ m.rotateY(math.radians(90))
+
v = Vector(cfg.innerWidth, cfg.innerDepth, cfg.innerHeight)
v.scale(moveX, moveY, moveZ)
- m = Matrix()
- m.rotateX(math.radians(rotX))
- m.rotateY(math.radians(rotY))
m.move(v)
return m
@@ -245,32 +252,32 @@ def makeBox(doc, cfg):
# right top bottom
s = Part.makePolygon(makeBoxSide(cfg, BoxSide.front))
- s.transformShape(m(90, 0, -0.5, -0.5, 0.5))
+ s.transformShape(m(True, False, -0.5, -0.5, 0.5))
front = doc.addObject("Part::Feature", "Front")
front.Shape = s
s = Part.makePolygon(makeBoxSide(cfg, BoxSide.back))
- s.transformShape(m(90, 0, -0.5, 0.5, 0.5))
+ s.transformShape(m(True, False, -0.5, 0.5, 0.5))
back = doc.addObject("Part::Feature", "Back")
back.Shape = s
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.left))
- l.transformShape(m(0, 90, -0.5, 0.5, 0.5))
+ l.transformShape(m(True, True, -0.5, -0.5, 0.5))
left = doc.addObject("Part::Feature", "Left")
left.Shape = l
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.right))
- l.transformShape(m(0, 90, 0.5, 0.5, 0.5))
+ l.transformShape(m(True, True, 0.5, -0.5, 0.5))
right = doc.addObject("Part::Feature", "Right")
right.Shape = l
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.top))
- l.transformShape(m(0, 0, -0.5, 0.5, 0.5))
+ l.transformShape(m(False, False, -0.5, 0.5, 0.5))
top = doc.addObject("Part::Feature", "Top")
top.Shape = l
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.bottom))
- l.transformShape(m(0, 0, -0.5, 0.5, -0.5))
+ l.transformShape(m(False, False, -0.5, 0.5, -0.5))
bottom = doc.addObject("Part::Feature", "Bottom")
bottom.Shape = l