[Free-cad-general] Understanding Vector in Python Script

 [Free-cad-general] Understanding Vector in Python Script From: Bernard - 2013-04-04 23:19:07 Hi, I am trying to understand how Base.Vector.add() works. I cannot understand why a result has twice the value of what I am expecting: import FreeCAD from FreeCAD import Base from FreeCAD import Part def WIDTH(): return 6.5 def HEIGHT(): return 3 def createBox(): vector1 = Base.Vector(WIDTH(), HEIGHT() / 2, 0) vector2 = vector1.add(Base.Vector(- WIDTH(), 0, 0)) # I expected vector3 to be at the same distance from the x axis as vector1 and vector1, i.e. HEIGHT() / 2 vector3 = vector2.add(Base.Vector(0, -HEIGHT(), 0))# Unexpected twice the distance vector4 = vector3.add(Base.Vector(WIDTH(), 0, 0)) lineEdge1 = Part.Line(vector1, vector2).toShape() lineEdge2 = Part.Line(vector2, vector3).toShape() lineEdge3 = Part.Line(vector3, vector4).toShape() lineEdge4 = Part.Line(vector4, vector1).toShape() wire = Part.Wire([lineEdge1, lineEdge2, lineEdge3, lineEdge4]) Part.show(wire) createBox() Would anybody be able to help? Many thanks, Bernard

 [Free-cad-general] Understanding Vector in Python Script From: Bernard - 2013-04-04 23:19:07 Hi, I am trying to understand how Base.Vector.add() works. I cannot understand why a result has twice the value of what I am expecting: import FreeCAD from FreeCAD import Base from FreeCAD import Part def WIDTH(): return 6.5 def HEIGHT(): return 3 def createBox(): vector1 = Base.Vector(WIDTH(), HEIGHT() / 2, 0) vector2 = vector1.add(Base.Vector(- WIDTH(), 0, 0)) # I expected vector3 to be at the same distance from the x axis as vector1 and vector1, i.e. HEIGHT() / 2 vector3 = vector2.add(Base.Vector(0, -HEIGHT(), 0))# Unexpected twice the distance vector4 = vector3.add(Base.Vector(WIDTH(), 0, 0)) lineEdge1 = Part.Line(vector1, vector2).toShape() lineEdge2 = Part.Line(vector2, vector3).toShape() lineEdge3 = Part.Line(vector3, vector4).toShape() lineEdge4 = Part.Line(vector4, vector1).toShape() wire = Part.Wire([lineEdge1, lineEdge2, lineEdge3, lineEdge4]) Part.show(wire) createBox() Would anybody be able to help? Many thanks, Bernard