def test_get_axis_frame_attachment_kwargs_for_right_face(self): right_faces = self.frame.Proxy.get_faces_for_side(Side.RIGHT) for right_face in right_faces: result = get_axis_frame_attachment_kwargs(self.frame, right_face, CoordinateAxis.Y) frame_size = self.frame.Size.Value three_inches = 76.2 # in millimeters (mm) length = frame_size + three_inches expected = { 'origin_translation_offset': Vector(0.0, 0.0, -1.0), 'placement': Placement( Vector( frame_size + AngleFrameConnector.axis_side_mount_width, -21.14446, # TODO: Replace magic number with something meaningful 305.2 # TODO: Replace magic number with something meaningful ), Rotation(), Vector()), 'length_value': length, 'orientation': CoordinateAxis.Y, 'side': Side.RIGHT } self.assert_result_and_expected_are_equal(result, expected)
def _get_axis_creation_kwargs(axis_orientation): selection_objects = Gui.Selection.getSelectionEx() try: frame, face = find_frame_and_face_in_selection(selection_objects) return get_axis_frame_attachment_kwargs(frame, face, axis_orientation) except AttachmentError as reason: log_message_template = '{}. Placing axis in default position.\n' Console.PrintMessage(log_message_template.format(reason)) return get_default_axis_creation_kwargs(axis_orientation)
def test_get_axis_frame_attachment_kwargs_for_front_face(self): front_face = self.frame.Proxy.get_faces_for_side(Side.FRONT)[0] result = get_axis_frame_attachment_kwargs(self.frame, front_face, CoordinateAxis.Z) expected = { 'origin_translation_offset': Vector(-0.5, -1.0, 0.0), 'placement': Placement(Vector(self.frame.Size / 2, 0, 0), Rotation(), Vector()), 'orientation': CoordinateAxis.Z, 'side': Side.FRONT } self.assert_result_and_expected_are_equal(result, expected)
def test_get_axis_frame_attachment_kwargs_for_right_face(self): right_face = self.frame.Proxy.get_faces_for_side(Side.RIGHT)[0] result = get_axis_frame_attachment_kwargs(self.frame, right_face, CoordinateAxis.Y) expected = { 'origin_translation_offset': Vector(0.0, 0.0, -1.0), 'placement': Placement(Vector(self.frame.Size, 0, self.frame.Size), Rotation(), Vector()), 'orientation': CoordinateAxis.Y, 'side': Side.RIGHT } self.assert_result_and_expected_are_equal(result, expected)
def test_get_axis_frame_attachment_kwargs_for_top_face(self): top_face = self.frame.Proxy.get_faces_for_side(Side.TOP)[0] result = get_axis_frame_attachment_kwargs(self.frame, top_face, CoordinateAxis.X) expected = { 'origin_translation_offset': Vector(0.0, -0.5, 0.0), 'placement': Placement(Vector(0, self.frame.Size / 2, self.frame.Size), Rotation()), 'orientation': CoordinateAxis.X, 'side': Side.TOP } self.assert_result_and_expected_are_equal(result, expected)
def test_get_axis_frame_attachment_kwargs_for_rear_face(self): rear_faces = self.frame.Proxy.get_faces_for_side(Side.REAR) for rear_face in rear_faces: result = get_axis_frame_attachment_kwargs(self.frame, rear_face, 'z') expected = { 'origin_translation_offset': Vector(-0.5, 0, 0), 'placement': Placement(Vector(self.frame.Size / 2, self.frame.Size, 0), Rotation(), Vector()), 'length_value': self.frame.Size.Value, 'orientation': CoordinateAxis.Z, 'side': Side.REAR } self.assert_result_and_expected_are_equal(result, expected)
def test_get_axis_frame_attachment_kwargs_for_bottom_face(self): bottom_face = self.frame.Proxy.get_faces_for_side(Side.BOTTOM)[0] with self.assertRaises(AttachmentError): get_axis_frame_attachment_kwargs(self.frame, bottom_face, CoordinateAxis.X)
def test_get_axis_frame_attachment_kwargs_for_bottom_face(self): bottom_faces = self.frame.Proxy.get_faces_for_side(Side.BOTTOM) for bottom_face in bottom_faces: with self.assertRaises(AttachmentError): get_axis_frame_attachment_kwargs(self.frame, bottom_face, 'x')