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
This commit is contained in:
qewer
2023-08-21 21:58:29 +03:00
committed by GitHub
parent 142b86fde2
commit dfbedc75b7
3 changed files with 55 additions and 59 deletions

View File

@@ -1,23 +1,23 @@
#***************************************************************************
#* Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
#* *
#* 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 <yorik@uncreated.net> *
# * *
# * 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)

View File

@@ -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 += '</ul>'

View File

@@ -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")