Draft: Independence from BIM (#17444)

* Draft: Independence from BIM - follow-up of #17390

* Draft: More info in DXF importer if BIM not present
This commit is contained in:
Yorik van Havre
2024-11-16 17:48:28 +01:00
committed by GitHub
parent 7183de92a4
commit ee2f384b2f
3 changed files with 51 additions and 34 deletions

View File

@@ -104,6 +104,22 @@ def errorDXFLib(gui):
-----
Use local variables, not global variables.
"""
def show_addon_message(gui):
if gui:
message = translate("Draft", """Download of dxf libraries failed.
Please install the dxf Library addon manually
from menu Tools -> Addon Manager""")
QtWidgets.QMessageBox.information(None, "", message)
else:
FCC.PrintWarning("The DXF import/export libraries needed by FreeCAD to handle the DXF format are not installed.\n")
FCC.PrintWarning("Please install the dxf Library addon from Tools -> Addon Manager\n")
try:
import ArchCommands
except:
# BIM not present
show_addon_message(gui)
return
dxfAllowDownload = params.get_param("dxfAllowDownload")
if dxfAllowDownload:
files = ['dxfColorMap.py', 'dxfImportObjects.py',
@@ -111,7 +127,6 @@ def errorDXFLib(gui):
baseurl = 'https://raw.githubusercontent.com/yorikvanhavre/'
baseurl += 'Draft-dxf-importer/master/'
import ArchCommands
from FreeCAD import Base
progressbar = Base.ProgressIndicator()
progressbar.start("Downloading files...", 4)
@@ -120,14 +135,7 @@ def errorDXFLib(gui):
p = None
p = ArchCommands.download(baseurl + f, force=True)
if not p:
if gui:
message = translate("Draft", """Download of dxf libraries failed.
Please install the dxf Library addon manually
from menu Tools -> Addon Manager""")
QtWidgets.QMessageBox.information(None, "", message)
else:
FCC.PrintWarning("The DXF import/export libraries needed by FreeCAD to handle the DXF format are not installed.\n")
FCC.PrintWarning("Please install the dxf Library addon from Tools -> Addon Manager\n")
show_addon_message(gui)
break
progressbar.stop()
sys.path.append(FreeCAD.ConfigGet("UserAppData"))