diff --git a/src/Mod/Arch/Resources/ui/preferences-ifc.ui b/src/Mod/Arch/Resources/ui/preferences-ifc.ui index 951b273da..ed66245b5 100644 --- a/src/Mod/Arch/Resources/ui/preferences-ifc.ui +++ b/src/Mod/Arch/Resources/ui/preferences-ifc.ui @@ -7,7 +7,7 @@ 0 0 456 - 486 + 542 @@ -20,6 +20,19 @@ 9 + + + + Show this dialog when importing and exporting + + + ifcShowDialog + + + Mod/Arch + + + diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 99f73605b..8ef267649 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -96,6 +96,7 @@ ENDSEC; END-ISO-10303-21; """ + def decode(filename,utf=False): if isinstance(filename,unicode): # workaround since ifcopenshell currently can't handle unicode filenames @@ -107,6 +108,7 @@ def decode(filename,utf=False): filename = filename.encode(encoding) return filename + def doubleClickTree(item,column): txt = item.text(column) if "Entity #" in txt: @@ -116,13 +118,41 @@ def doubleClickTree(item,column): tree.scrollToItem(addr[0]) addr[0].setSelected(True) + +def getPreferences(): + """retrieves IFC preferences""" + global DEBUG, PREFIX_NUMBERS, SKIP, SEPARATE_OPENINGS, + ROOT_ELEMENT, GET_EXTRUSIONS, MERGE_MATERIALS, + MERGE_MODE_ARCH, MERGE_MODE_STRUCT, CREATE_CLONES, + FORCE_BREP + p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") + if FreeCAD.GuiUp and p.GetBool("ifcShowDialog",False): + import FreeCADGui + FreeCADGui.showPreferences("Import-Export",0) + DEBUG = p.GetBool("ifcDebug",False) + PREFIX_NUMBERS = p.GetBool("ifcPrefixNumbers",False) + SKIP = p.GetString("ifcSkip","").split(",") + SEPARATE_OPENINGS = p.GetBool("ifcSeparateOpenings",False) + ROOT_ELEMENT = p.GetString("ifcRootElement","IfcProduct") + GET_EXTRUSIONS = p.GetBool("ifcGetExtrusions",False) + MERGE_MATERIALS = p.GetBool("ifcMergeMaterials",False) + MERGE_MODE_ARCH = p.GetInt("ifcImportModeArch",0) + MERGE_MODE_STRUCT = p.GetInt("ifcImportModeStruct",1) + if MERGE_MODE_ARCH > 0: + SEPARATE_OPENINGS = False + GET_EXTRUSIONS = False + if not SEPARATE_OPENINGS: + SKIP.append("IfcOpeningElement") + CREATE_CLONES = p.GetBool("ifcCreateClones",True) + FORCEBREP = p.GetBool("ifcExportAsBrep",False) + + def explore(filename=None): """explore([filename]): opens a dialog showing the contents of an IFC file. If no filename is given, a dialog will pop up to choose a file.""" - - p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") - DEBUG = p.GetBool("ifcDebug",False) + + getPreferences() try: import ifcopenshell @@ -287,24 +317,7 @@ def insert(filename,docname,skip=[],only=[],root=None): certain object ids (will also get their children) and root can be used to import only the derivates of a certain element type (default = ifcProduct).""" - p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") - DEBUG = p.GetBool("ifcDebug",False) - PREFIX_NUMBERS = p.GetBool("ifcPrefixNumbers",False) - SKIP = p.GetString("ifcSkip","").split(",") - SEPARATE_OPENINGS = p.GetBool("ifcSeparateOpenings",False) - ROOT_ELEMENT = p.GetString("ifcRootElement","IfcProduct") - GET_EXTRUSIONS = p.GetBool("ifcGetExtrusions",False) - MERGE_MATERIALS = p.GetBool("ifcMergeMaterials",False) - if root: - ROOT_ELEMENT = root - MERGE_MODE_ARCH = p.GetInt("ifcImportModeArch",0) - MERGE_MODE_STRUCT = p.GetInt("ifcImportModeStruct",1) - if MERGE_MODE_ARCH > 0: - SEPARATE_OPENINGS = False - GET_EXTRUSIONS = False - if not SEPARATE_OPENINGS: - SKIP.append("IfcOpeningElement") - CREATE_CLONES = p.GetBool("ifcCreateClones",True) + getPreferences() try: import ifcopenshell @@ -320,6 +333,9 @@ def insert(filename,docname,skip=[],only=[],root=None): FreeCAD.ActiveDocument = doc if DEBUG: print "done." + + if root: + ROOT_ELEMENT = root #global ifcfile # keeping global for debugging purposes filename = decode(filename,utf=True) @@ -789,9 +805,7 @@ def insert(filename,docname,skip=[],only=[],root=None): def export(exportList,filename): "exports FreeCAD contents to an IFC file" - p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") - FORCEBREP = p.GetBool("ifcExportAsBrep",False) - DEBUG = p.GetBool("ifcDebug",False) + getPreferences() try: global ifcopenshell diff --git a/src/Mod/Draft/Resources/ui/preferences-dxf.ui b/src/Mod/Draft/Resources/ui/preferences-dxf.ui index 76952cfda..d3321bcf5 100644 --- a/src/Mod/Draft/Resources/ui/preferences-dxf.ui +++ b/src/Mod/Draft/Resources/ui/preferences-dxf.ui @@ -7,7 +7,7 @@ 0 0 506 - 564 + 611 @@ -20,10 +20,42 @@ 9 + + + + Show this dialog when importing and exporting + + + dxfShowDialog + + + Mod/Draft + + + + + + + If this is checked, the old python importer is used, otherwise the new C++ one (faster, but not as many features yet) + + + Use legacy python importer + + + true + + + dxfUseLegacyImporter + + + Mod/Draft + + + - Automatic update + Automatic update (legacy importer only) @@ -61,29 +93,6 @@ 9 - - - - - - If this is checked, the old python importer is used, otherwise the new C++ one (faster, but not as many features yet) - - - Use legacy python importer - - - true - - - dxfUseLegacyImporter - - - Mod/Draft - - - - - diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 112367ea8..72bbe9392 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -2010,6 +2010,9 @@ def exportPageLegacy(page,filename): def readPreferences(): # reading parameters p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") + if FreeCAD.GuiUp and p.GetBool("dxfShowDialog",False): + import FreeCADGui + FreeCADGui.showPreferences("Import-Export",2) global dxfCreatePart, dxfCreateDraft, dxfCreateSketch, dxfDiscretizeCurves, dxfStarBlocks global dxfMakeBlocks, dxfJoin, dxfRenderPolylineWidth, dxfImportTexts, dxfImportLayouts global dxfImportPoints, dxfImportHatches, dxfUseStandardSize, dxfGetColors, dxfUseDraftVisGroups