def RotatingFace_cb(self, userData=None): """[Rotation of the face by using the discs. This is the callback used for all axis (X,Y and Z)] Args: userData ([type], optional): [description]. Defaults to None. """ events = userData.events if type(events) != int: print("event was not int") return if self.discObj.w_userData.Disc_cb is False: if self.discObj.w_userData.Axis_cb is True: self.MouseDragging_cb(userData) return else: return # We cannot allow this tool self.oldFaceVertexes = self.newFaceVertexes s = App.ActiveDocument.getObject(self.newFace.Name) s.Placement = self.OriginalFacePlacement if self.discObj.w_userData.discObj.axisType == 'X': faced.RotateObjectToCenterPoint( self.newFace, 0, 0, self.discObj.w_userData.discObj.w_discAngle[0]) elif self.discObj.w_userData.discObj.axisType == 'Y': faced.RotateObjectToCenterPoint( self.newFace, 0, self.discObj.w_userData.discObj.w_discAngle[1], 0) elif self.discObj.w_userData.discObj.axisType == 'Z': faced.RotateObjectToCenterPoint( self.newFace, self.discObj.w_userData.discObj.w_discAngle[2], 0, 0, ) self.newFaceVertexes = self.newFace.Shape.Vertexes self.COIN_recreateObject()
def calculateRotatedNormal(self, Wheelaxis): """[calculate placement, angle of rotation, axis of rotation based on the] Args: Wheelaxis ([str]): [Direction of the wheel coin widget - Axis type ] Returns: [Base.placement]: [Placement, rotation angle and axis of rotation for face2] """ if self.isItRotation is True: return # We shouldn't be here. faceRotation = 0 # TODO: Lets take only X axis first , then Y ..etc and so on. face1Obj = self.ExtractedFaces[0] pl = self.ExtractedFaces[0].Placement self.faceDir = faced.getDirectionAxis(self.selected) # face direction # THIS PART WILL BE COMPLICATED AND MUST BE WELL WRITTEN. # Wheelaxis color: RED is X , GREEN is Y, FR_BLUEVIOLET is 45 and ORANGE is 135 s = self.ExtractedFaces[1] # Reset the placement of the object if was not correct s.Placement = self.ExtractedFaces[0].Placement ax = self.selectedObj.Object.Shape.CenterOfMass if self.faceDir == "+x" and Wheelaxis == "X": faced.RealRotateObjectToAnAxis(s, ax, 0, 90, 0) self.ExtractedFaces[1].Placement.Base.x = self.ExtractedFaces[1].Placement.Base.x + \ self.ExtractedFaces[1].Shape.BoundBox.XLength pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-x" and Wheelaxis == "X": faced.RealRotateObjectToAnAxis(s, ax, 0, 90, 0) self.ExtractedFaces[1].Placement.Base.x = self.ExtractedFaces[1].Placement.Base.x - \ self.ExtractedFaces[1].Shape.BoundBox.XLength pl = self.ExtractedFaces[1].Placement elif (self.faceDir == "+x" and Wheelaxis == "Y") or (self.faceDir == "-x" and Wheelaxis == "Y"): # We do nothing .. it is ok to not change pl = self.ExtractedFaces[1].Placement elif self.faceDir == "+y" and Wheelaxis == "X": faced.RealRotateObjectToAnAxis(s, ax, 0, 0, -90) self.ExtractedFaces[1].Placement.Base.y = self.ExtractedFaces[1].Placement.Base.y + \ self.ExtractedFaces[1].Shape.BoundBox.YLength pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-y" and Wheelaxis == "X": faced.RealRotateObjectToAnAxis(s, ax, 0, 0, 90) self.ExtractedFaces[1].Placement.Base.y = self.ExtractedFaces[1].Placement.Base.y - \ self.ExtractedFaces[1].Shape.BoundBox.YLength pl = self.ExtractedFaces[1].Placement elif (self.faceDir == "+y" and Wheelaxis == "Y") or (self.faceDir == "-y" and Wheelaxis == "Y"): pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-z" and Wheelaxis == "X" or ( self.faceDir == "+z" and Wheelaxis == "X"): pl = self.ExtractedFaces[1].Placement elif self.faceDir == "+z" and Wheelaxis == "Y": faced.RealRotateObjectToAnAxis(s, ax, 0, 0, -90) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-z" and Wheelaxis == "Y": faced.RealRotateObjectToAnAxis(s, ax, 0, 0, 90) pl = self.ExtractedFaces[1].Placement # Now we have 45Degrees : if self.faceDir == "+x" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 45, 0) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-x" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 45, 0) pl = self.ExtractedFaces[1].Placement # Now we have 45 Degrees : if self.faceDir == "+y" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 0, -45) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-y" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 0, -45) pl = self.ExtractedFaces[1].Placement # Now we have 45 and 135 Degrees : if self.faceDir == "+z" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 0, 45) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-z" and Wheelaxis == "45": faced.RotateObjectToCenterPoint(s, 0, 0, 45) pl = self.ExtractedFaces[1].Placement # Now we have 135 Degrees : if self.faceDir == "+x" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 135, 0) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-x" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 135, 0) pl = self.ExtractedFaces[1].Placement if self.faceDir == "+y" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 0, -135) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-y" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 0, -135) pl = self.ExtractedFaces[1].Placement if self.faceDir == "+z" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 0, 135) pl = self.ExtractedFaces[1].Placement elif self.faceDir == "-z" and Wheelaxis == "135": faced.RotateObjectToCenterPoint(s, 0, 0, 135) pl = self.ExtractedFaces[1].Object.Placement return pl