コード例 #1
0
ファイル: DraftSnap.py プロジェクト: msocorcim/FreeCAD
 def snapToPolar(self,point,last):
     "snaps to polar lines from the given point"
     if self.isEnabled('ortho'): 
         if last:
             vecs = []
             if hasattr(FreeCAD,"DraftWorkingPlane"):
                 ax = [FreeCAD.DraftWorkingPlane.u,
                        FreeCAD.DraftWorkingPlane.v,
                        FreeCAD.DraftWorkingPlane.axis]
             else:
                 ax = [FreeCAD.Vector(1,0,0),
                       FreeCAD.Vector(0,1,0),
                       FreeCAD.Vector(0,0,1)]
             for a in self.polarAngles:
                     if a == 90:
                         vecs.extend([ax[0],fcvec.neg(ax[0])])
                         vecs.extend([ax[1],fcvec.neg(ax[1])])
                     else:
                         v = fcvec.rotate(ax[0],math.radians(a),ax[2])
                         vecs.extend([v,fcvec.neg(v)])
                         v = fcvec.rotate(ax[1],math.radians(a),ax[2])
                         vecs.extend([v,fcvec.neg(v)])
             for v in vecs:
                 de = Part.Line(last,last.add(v)).toShape()  
                 np = self.getPerpendicular(de,point)
                 if (np.sub(point)).Length < self.radius:
                     if self.tracker:
                         self.tracker.setCoords(np)
                         self.tracker.setMarker(self.mk['parallel'])
                         self.tracker.on()
                         self.setCursor('ortho')
                     return np,de
     return point,None
コード例 #2
0
ファイル: WorkingPlane.py プロジェクト: msocorcim/FreeCAD
	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
コード例 #3
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