Exemplo n.º 1
0
	def alignToPointAndAxis(self, point, axis, offset, upvec=None):
		self.doc = FreeCAD.ActiveDocument
		self.axis = axis;
		self.axis.normalize()
		if (fcvec.equals(axis, Vector(1,0,0))):
			self.u = Vector(0,1,0)
			self.v = Vector(0,0,1)
                elif (fcvec.equals(axis, Vector(-1,0,0))):
                        self.u = Vector(0,-1,0)
                        self.v = Vector(0,0,1)
                elif upvec:
                        self.v = upvec
                        self.v.normalize()
                        self.u = self.v.cross(self.axis)
		else:
			self.v = axis.cross(Vector(1,0,0))
			self.v.normalize()
			self.u = fcvec.rotate(self.v, -math.pi/2, self.axis)
		offsetVector = Vector(axis); offsetVector.multiply(offset)
		self.position = point.add(offsetVector)
		self.weak = False
Exemplo n.º 2
0
 def alignToPointAndAxis(self, point, axis, offset, upvec=None):
     self.doc = FreeCAD.ActiveDocument
     self.axis = axis
     self.axis.normalize()
     if (fcvec.equals(axis, Vector(1, 0, 0))):
         self.u = Vector(0, 1, 0)
         self.v = Vector(0, 0, 1)
     elif (fcvec.equals(axis, Vector(-1, 0, 0))):
         self.u = Vector(0, -1, 0)
         self.v = Vector(0, 0, 1)
     elif upvec:
         self.v = upvec
         self.v.normalize()
         self.u = self.v.cross(self.axis)
     else:
         self.v = axis.cross(Vector(1, 0, 0))
         self.v.normalize()
         self.u = fcvec.rotate(self.v, -math.pi / 2, self.axis)
     offsetVector = Vector(axis)
     offsetVector.multiply(offset)
     self.position = point.add(offsetVector)
     self.weak = False
Exemplo n.º 3
0
 def calc(self):
     import Part
     if (self.p1 != None) and (self.p2 != None):
         points = [fcvec.tup(self.p1,True),fcvec.tup(self.p2,True),\
                       fcvec.tup(self.p1,True),fcvec.tup(self.p2,True)]
         if self.p3 != None:
             p1 = self.p1
             p4 = self.p2
             if fcvec.equals(p1,p4):
                 proj = None
             else:
                 base = Part.Line(p1,p4).toShape()
                 proj = fcgeo.findDistance(self.p3,base)
             if not proj:
                 p2 = p1
                 p3 = p4
             else:
                 p2 = p1.add(fcvec.neg(proj))
                 p3 = p4.add(fcvec.neg(proj))
             points = [fcvec.tup(p1),fcvec.tup(p2),fcvec.tup(p3),fcvec.tup(p4)]
         self.coords.point.setValues(0,4,points)