Пример #1
0
def enforce_fillbox_restrictions():
    """ Enforces restrictions on all fillboxes, resetting their rotations to 0. """
    for target in filter(
            lambda obj: obj.TypeId == FreeCADObjectType.FOLDER and "fillbox" in
            obj.Name.lower(), FreeCAD.ActiveDocument.Objects):
        for sub_element in target.OutList:
            if sub_element.Placement.Rotation.Angle != 0.0:
                sub_element.Placement.Rotation.Angle = 0.0
                error(__("Can't change rotation on Fillbox inner objects"))
Пример #2
0
def enforce_case_limits_restrictions(mode_3d_enabled: bool = True):
    """ Enforces restrictions on the case limit object within FreeCAD, like rotation and width (in 2D mode). """
    case_limits_view = get_fc_view_object(CASE_LIMITS_OBJ_NAME)
    case_limits = get_fc_object(CASE_LIMITS_OBJ_NAME)
    if case_limits_view.DisplayMode != FreeCADDisplayMode.WIREFRAME:
        case_limits_view.DisplayMode = FreeCADDisplayMode.WIREFRAME
    if case_limits_view.LineColor != (1.00, 0.00, 0.00):
        case_limits_view.LineColor = (1.00, 0.00, 0.00)
    if case_limits_view.Selectable:
        case_limits_view.Selectable = False
    if case_limits.Placement.Rotation.Angle != 0.0:
        case_limits.Placement.Rotation.Angle = 0.0
        error(__("Can't change rotation on the Case Limits object."))
    if not mode_3d_enabled and case_limits.Width.Value != WIDTH_2D:
        case_limits.Width.Value = WIDTH_2D
        error(
            __("Can't change width of the Case Limits object while being in 2D mode."
               ))
    def on_2d_toggle(self):
        """ Handles Toggle 3D/2D Button. Changes the Case Limits object accordingly. """
        if not valid_document_environment():
            error("Not a valid case environment")
            return

        fc_object = get_fc_object(CASE_LIMITS_OBJ_NAME)

        if Case.the().mode3d:
            # 3D to 2D
            Case.the().info.last_3d_width = fc_object.Width.Value
            config_dialog = Mode2DConfigDialog(fc_object.Placement.Base.y,
                                               parent=get_fc_main_window())
            if config_dialog.exit_status == QtGui.QDialog.Rejected:
                return
            fc_object.Placement.Base.y = float(config_dialog.stored_y_value)
            fc_object.Label = CASE_LIMITS_2D_LABEL
            Case.the().mode3d = not Case.the().mode3d
        else:
            # 2D to 3D
            Case.the().mode3d = not Case.the().mode3d
            fc_object.Width = Case.the().info.last_3d_width if Case.the(
            ).info.last_3d_width > 0.0 else fc_object.Length
            fc_object.Label = CASE_LIMITS_3D_LABEL
Пример #4
0
                if isinstance(movement.generator, (FileGen, RotationFileGen)):
                    filename = movement.generator.filename
                    debug("Copying {} to {}".format(filename, save_name))

                    # Change directory to de case one, so if file path is already relative it copies it to the
                    # out folder
                    chdir(save_name)

                    try:
                        # Copy to project root
                        shutil.copy2(filename, save_name)
                    except shutil.Error:
                        # Probably already copied the file.
                        pass
                    except IOError:
                        error("Unable to copy {} into {}".format(filename, save_name))

                    try:
                        # Copy to project out folder
                        shutil.copy2(filename, save_name + "/" + project_name + "_out")

                        movement.generator.filename = "{}".format(filename.split("/")[-1])
                    except shutil.Error:
                        # Probably already copied the file.
                        pass
                    except IOError:
                        error("Unable to copy {} into {}".format(filename, save_name + "/" + project_name + "_out"))

    # Copy files from Acceleration input and change paths to be inside the project folder.
    for aid in case.acceleration_input.acclist:
        filename = aid.datafile