From dfbedc75b7296cfff6f63fa31e8d65972cae87f3 Mon Sep 17 00:00:00 2001 From: qewer <69015181+qewer33@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:58:29 +0300 Subject: [PATCH] StartPage: Fix new file templates issues (#10291) * Make StartPage new file template buttons use if instead of match * Make StartPage Part design new file template not create a sketch * Remove StartPage Part new file template and rename Part Design template based on community feedback * StartPage LoadNew.py fix indentation --- src/Mod/Start/StartPage/LoadNew.py | 104 ++++++++++---------- src/Mod/Start/StartPage/StartPage.py | 4 +- src/Mod/Start/StartPage/TranslationTexts.py | 6 +- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/src/Mod/Start/StartPage/LoadNew.py b/src/Mod/Start/StartPage/LoadNew.py index 0caf12e5b2..be697589ae 100644 --- a/src/Mod/Start/StartPage/LoadNew.py +++ b/src/Mod/Start/StartPage/LoadNew.py @@ -1,23 +1,23 @@ -#*************************************************************************** -#* Copyright (c) 2018 Yorik van Havre * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* This program is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Library General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with this program; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#*************************************************************************** +# *************************************************************************** +# * Copyright (c) 2018 Yorik van Havre * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** import FreeCAD import FreeCADGui @@ -26,37 +26,33 @@ from StartPage import StartPage # template will be given before this script is run template_name = str(template) -match template_name: - case "empty_file": - FreeCADGui.runCommand('Std_New') - StartPage.postStart() - case "import_file": - FreeCADGui.runCommand('Std_New') - StartPage.postStart() - FreeCADGui.runCommand("Std_Import") - case "parametric_part": - FreeCADGui.runCommand('Std_New') - FreeCADGui.activateWorkbench("PartDesignWorkbench") - FreeCADGui.runCommand("PartDesign_Body") - FreeCADGui.Selection.addSelection('Unnamed','Body') - FreeCADGui.runCommand('PartDesign_NewSketch',0) - FreeCADGui.Selection.clearSelection() - StartPage.postStart(False) - case "csg_part": - FreeCADGui.runCommand('Std_New') - FreeCADGui.activateWorkbench("PartWorkbench") - StartPage.postStart(False) - case "2d_draft": - FreeCADGui.runCommand('Std_New') - FreeCADGui.activateWorkbench("DraftWorkbench") - FreeCADGui.runCommand("Std_ViewTop") - StartPage.postStart(False) - case "architecture": - FreeCADGui.runCommand('Std_New') - try: - import BimCommands - except Exception: - FreeCADGui.activateWorkbench("ArchWorkbench") - else: - FreeCADGui.activateWorkbench("BIMWorkbench") - StartPage.postStart(False) +if template_name == "empty_file": + FreeCADGui.runCommand('Std_New') + StartPage.postStart() +elif template_name == "import_file": + FreeCADGui.runCommand('Std_New') + StartPage.postStart() + FreeCADGui.runCommand("Std_Import") +elif template_name == "parametric_part": + FreeCADGui.runCommand('Std_New') + FreeCADGui.activateWorkbench("PartDesignWorkbench") + FreeCADGui.runCommand("PartDesign_Body") + StartPage.postStart(False) +# elif template_name == "csg_part": +# FreeCADGui.runCommand('Std_New') +# FreeCADGui.activateWorkbench("PartWorkbench") +# StartPage.postStart(False) +elif template_name == "2d_draft": + FreeCADGui.runCommand('Std_New') + FreeCADGui.activateWorkbench("DraftWorkbench") + FreeCADGui.runCommand("Std_ViewTop") + StartPage.postStart(False) +elif template_name == "architecture": + FreeCADGui.runCommand('Std_New') + try: + import BimCommands + except Exception: + FreeCADGui.activateWorkbench("ArchWorkbench") + else: + FreeCADGui.activateWorkbench("BIMWorkbench") + StartPage.postStart(False) diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index 8ab0abba8a..ef44b5ef9e 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -259,7 +259,7 @@ def build_new_file_card(template): "empty_file": [TranslationTexts.T_TEMPLATE_EMPTYFILE_NAME, TranslationTexts.T_TEMPLATE_EMPTYFILE_DESC], "import_file": [TranslationTexts.T_TEMPLATE_IMPORTFILE_NAME, TranslationTexts.T_TEMPLATE_IMPORTFILE_DESC], "parametric_part": [TranslationTexts.T_TEMPLATE_PARAMETRICPART_NAME, TranslationTexts.T_TEMPLATE_PARAMETRICPART_DESC], - "csg_part": [TranslationTexts.T_TEMPLATE_CSGPART_NAME, TranslationTexts.T_TEMPLATE_CSGPART_DESC], + # "csg_part": [TranslationTexts.T_TEMPLATE_CSGPART_NAME, TranslationTexts.T_TEMPLATE_CSGPART_DESC], "2d_draft": [TranslationTexts.T_TEMPLATE_2DDRAFT_NAME, TranslationTexts.T_TEMPLATE_2DDRAFT_DESC], "architecture": [TranslationTexts.T_TEMPLATE_ARCHITECTURE_NAME, TranslationTexts.T_TEMPLATE_ARCHITECTURE_DESC] } @@ -430,7 +430,7 @@ def handle(): SECTION_NEW_FILE += build_new_file_card("empty_file") SECTION_NEW_FILE += build_new_file_card("import_file") SECTION_NEW_FILE += build_new_file_card("parametric_part") - SECTION_NEW_FILE += build_new_file_card("csg_part") + # SECTION_NEW_FILE += build_new_file_card("csg_part") SECTION_NEW_FILE += build_new_file_card("2d_draft") SECTION_NEW_FILE += build_new_file_card("architecture") SECTION_NEW_FILE += '' diff --git a/src/Mod/Start/StartPage/TranslationTexts.py b/src/Mod/Start/StartPage/TranslationTexts.py index 706443fc98..f5b61dd1bc 100644 --- a/src/Mod/Start/StartPage/TranslationTexts.py +++ b/src/Mod/Start/StartPage/TranslationTexts.py @@ -43,10 +43,10 @@ T_TEMPLATE_EMPTYFILE_NAME = translate("StartPage", "Empty File") T_TEMPLATE_EMPTYFILE_DESC = translate("StartPage", "Create an empty FreeCAD file") T_TEMPLATE_IMPORTFILE_NAME = translate("StartPage", "Import File") T_TEMPLATE_IMPORTFILE_DESC = translate("StartPage", "Work on an existing CAD file or 3D model") -T_TEMPLATE_PARAMETRICPART_NAME = translate("StartPage", "Parametric Part") +T_TEMPLATE_PARAMETRICPART_NAME = translate("StartPage", "Standard Part") T_TEMPLATE_PARAMETRICPART_DESC = translate("StartPage", "Create a part with the Part Design workbench") -T_TEMPLATE_CSGPART_NAME = translate("StartPage", "CSG Part") -T_TEMPLATE_CSGPART_DESC = translate("StartPage", "Create a part with the Part workbench") +# T_TEMPLATE_CSGPART_NAME = translate("StartPage", "CSG Part") +# T_TEMPLATE_CSGPART_DESC = translate("StartPage", "Create a part with the Part workbench") T_TEMPLATE_2DDRAFT_NAME = translate("StartPage", "2D Draft") T_TEMPLATE_2DDRAFT_DESC = translate("StartPage", "Create a 2D draft with the Draft workbench") T_TEMPLATE_ARCHITECTURE_NAME = translate("StartPage", "BIM/Architecture")