diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 114ab60342..61635d21ab 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -1142,7 +1142,7 @@ def toggleIfcBrepFlag(obj): FreeCAD.Console.PrintMessage(translate("Arch","Object doesn't have settable IFCData")) else: d = obj.IfcData - if "FlagForceBrep" in d.keys(): + if "FlagForceBrep" in d: if d["FlagForceBrep"] == "True": d["FlagForceBrep"] = "False" FreeCAD.Console.PrintMessage(translate("Arch","Disabling Brep force flag of object")+" "+obj.Label+"\n") diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 7b29c76298..fc2d4c6a3f 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -1983,7 +1983,7 @@ class ComponentTaskPanel: import ArchIFCSchema # get presets - self.ptypes = list(ArchIFCSchema.IfcTypes.keys()) + self.ptypes = list(ArchIFCSchema.IfcTypes) self.plabels = [''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in self.ptypes] self.psetdefs = {} psetspath = os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","pset_definitions.csv") diff --git a/src/Mod/Arch/ArchIFC.py b/src/Mod/Arch/ArchIFC.py index 2543d1e7a3..2f96f4aff0 100644 --- a/src/Mod/Arch/ArchIFC.py +++ b/src/Mod/Arch/ArchIFC.py @@ -134,7 +134,7 @@ class IfcRoot: IfcData["complex_attributes"] = "{}" ifcComplexAttributes = json.loads(IfcData["complex_attributes"]) for attribute in ifcTypeSchema["complex_attributes"]: - if attribute["name"] not in ifcComplexAttributes.keys(): + if attribute["name"] not in ifcComplexAttributes: ifcComplexAttributes[attribute["name"]] = {} IfcData["complex_attributes"] = json.dumps(ifcComplexAttributes) obj.IfcData = IfcData diff --git a/src/Mod/Arch/ArchIFCView.py b/src/Mod/Arch/ArchIFCView.py index 4703d492b2..c4d4617ce9 100644 --- a/src/Mod/Arch/ArchIFCView.py +++ b/src/Mod/Arch/ArchIFCView.py @@ -152,7 +152,7 @@ class IfcContextUI: """ data = ArchIFC.IfcRoot.getObjIfcComplexAttribute(self, self.object, "RepresentationContexts") for lineEdit in self.lineEditObjects: - if lineEdit.objectName() in data.keys(): + if lineEdit.objectName() in data: lineEdit.setText(data[lineEdit.objectName()]) def createFormEntry(self, name, label): diff --git a/src/Mod/Arch/ArchMaterial.py b/src/Mod/Arch/ArchMaterial.py index ce74d5da99..a4f7f08f44 100644 --- a/src/Mod/Arch/ArchMaterial.py +++ b/src/Mod/Arch/ArchMaterial.py @@ -699,7 +699,7 @@ class _ArchMaterialTaskPanel: if e.upper() == ".FCMAT": self.cards[b] = p + os.sep + f if self.cards: - for k in sorted(self.cards.keys()): + for k in sorted(self.cards): self.form.comboBox_MaterialsInDir.addItem(k) def fillExistingCombo(self): diff --git a/src/Mod/Arch/ArchReference.py b/src/Mod/Arch/ArchReference.py index 5021e6bcad..b07c562baa 100644 --- a/src/Mod/Arch/ArchReference.py +++ b/src/Mod/Arch/ArchReference.py @@ -680,11 +680,12 @@ class ArchReferenceTaskPanel: parts = self.obj.Proxy.parts else: parts = self.obj.Proxy.getPartsList(self.obj) - for k in sorted(parts.keys()): + sortedkeys = sorted(parts) + for k in sortedkeys: self.partCombo.addItem(parts[k][0],k) if self.obj.Part: - if self.obj.Part in parts.keys(): - self.partCombo.setCurrentIndex(sorted(parts.keys()).index(self.obj.Part)) + if self.obj.Part in sortedkeys: + self.partCombo.setCurrentIndex(sortedkeys.index(self.obj.Part)) QtCore.QObject.connect(self.fileButton, QtCore.SIGNAL("clicked()"), self.chooseFile) QtCore.QObject.connect(self.openButton, QtCore.SIGNAL("clicked()"), self.openFile) @@ -722,11 +723,12 @@ class ArchReferenceTaskPanel: parts = self.obj.Proxy.getPartsList(self.obj,self.filename) if parts: self.partCombo.clear() - for k in sorted(parts.keys()): + sortedkeys = sorted(parts) + for k in sortedkeys: self.partCombo.addItem(parts[k][0],k) if self.obj.Part: - if self.obj.Part in parts.keys(): - self.partCombo.setCurrentIndex(sorted(parts.keys()).index(self.obj.Part)) + if self.obj.Part in sortedkeys: + self.partCombo.setCurrentIndex(sortedkeys.index(self.obj.Part)) def openFile(self): diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index 0d0e9c78c9..a47648003c 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -514,7 +514,7 @@ def export(exportList, filename, colors=None, preferences=None): if preferences["DEBUG"]: print("Warning! Axis system object '{}' only contains one set of axis but at least two are needed for a IfcGrid to be added to IFC.".format(obj.Label)) continue - if ifctype not in ArchIFCSchema.IfcProducts.keys(): + if ifctype not in ArchIFCSchema.IfcProducts: ifctype = "IfcBuildingElementProxy" # getting the representation @@ -1017,7 +1017,7 @@ def export(exportList, filename, colors=None, preferences=None): for c in objs: if not (c.Name in treated): if c.Name != building.Name: # get_group_contents + addgroups will include the building itself - if c.Name in products.keys(): + if c.Name in products: if Draft.getType(c) in ["Floor","BuildingPart","Space"]: childfloors.append(products[c.Name]) treated.append(c.Name) @@ -1056,7 +1056,7 @@ def export(exportList, filename, colors=None, preferences=None): childbuildings = [] for c in objs: if c.Name != site.Name: # get_group_contents + addgroups will include the building itself - if c.Name in products.keys(): + if c.Name in products: if not (c.Name in treated): if Draft.getType(c) == "Building": childbuildings.append(products[c.Name]) @@ -1427,7 +1427,7 @@ def export(exportList, filename, colors=None, preferences=None): if okay: sortedgroups.append([g,groups[g]]) for g in sortedgroups: - if g[0] in groups.keys(): + if g[0] in groups: del groups[g[0]] #print("sorted groups:",sortedgroups) containers = {} @@ -1435,9 +1435,9 @@ def export(exportList, filename, colors=None, preferences=None): if g[1]: children = [] for o in g[1]: - if o in products.keys(): + if o in products: children.append(products[o]) - elif o in annos.keys(): + elif o in annos: children.append(annos[o]) swallowed.append(annos[o]) if children: @@ -1705,7 +1705,7 @@ def getIfcTypeFromObj(obj): else: ifctype = dtype - if ifctype in translationtable.keys(): + if ifctype in translationtable: ifctype = translationtable[ifctype] if not ifctype.startswith("Ifc"): ifctype = "Ifc" + ifctype @@ -2383,7 +2383,7 @@ def getBrepFlag(obj,preferences): if preferences['FORCE_BREP']: return True if hasattr(obj,"IfcData"): - if "FlagForceBrep" in obj.IfcData.keys(): + if "FlagForceBrep" in obj.IfcData: if obj.IfcData["FlagForceBrep"] == "True": brepflag = True return brepflag @@ -2414,7 +2414,7 @@ def createProduct(ifcfile,obj,ifctype,uid,history,name,description,placement,rep kwargs = exportIfcAttributes(obj, kwargs, preferences['SCALE_FACTOR']) # in some cases object have wrong ifctypes, thus set it # https://forum.freecad.org/viewtopic.php?f=39&t=50085 - if ifctype not in ArchIFCSchema.IfcProducts.keys(): + if ifctype not in ArchIFCSchema.IfcProducts: # print("Wrong IfcType: IfcBuildingElementProxy is used. {}".format(ifctype)) ifctype = "IfcBuildingElementProxy" # print("createProduct: {}".format(ifctype)) @@ -2429,7 +2429,7 @@ def getUID(obj,preferences): global uids uid = None if hasattr(obj,"IfcData"): - if "IfcUID" in obj.IfcData.keys(): + if "IfcUID" in obj.IfcData: uid = str(obj.IfcData["IfcUID"]) if uid in uids: # this UID has already been used in another object diff --git a/src/Mod/Arch/importDAE.py b/src/Mod/Arch/importDAE.py index 5c5def7693..2dfaad11b7 100644 --- a/src/Mod/Arch/importDAE.py +++ b/src/Mod/Arch/importDAE.py @@ -138,7 +138,7 @@ def read(filename): if tnode is not None: mnode = tnode.find(bt+"instance_material") if mnode is not None: - if "target" in mnode.keys(): + if "target" in mnode: mname = mnode.get("target").strip("#") for m in col.materials: if m.id == mname: diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 115e203a5f..d05aac8e8d 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -323,7 +323,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): while only: currentid = only.pop() ids.append(currentid) - if currentid in additions.keys(): + if currentid in additions: only.extend(additions[currentid]) products = [ifcfile[currentid] for currentid in ids] @@ -370,7 +370,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): lays = product.Representation.Representations[0].LayerAssignments if len(lays) > 0: layer_name = lays[0].Name - if layer_name not in list(layers.keys()): + if layer_name not in layers: layers[layer_name] = [pid] else: layers[layer_name].append(pid) @@ -943,7 +943,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if ifcfile[host].is_a("IfcStructuralAnalysisModel"): compound = [] for c in children: - if c in structshapes.keys(): + if c in structshapes: compound.append(structshapes[c]) del structshapes[c] if compound: @@ -969,11 +969,11 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # print(host, ' --> ', children) obj = doc.addObject("App::DocumentObjectGroup","AnalysisModel") objects[host] = obj - if host in objects.keys(): + if host in objects: cobs = [] childs_to_delete = [] for child in children: - if child in objects.keys(): + if child in objects: cobs.append(objects[child]) childs_to_delete.append(child) for c in childs_to_delete: @@ -1009,7 +1009,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): grp.Label = grp_name objects[host] = grp for child in children: - if child in objects.keys(): + if child in objects: grp.addObject(objects[child]) swallowed.append(child) else: @@ -1025,12 +1025,12 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if ifcfile[host].is_a("IfcBuildingStorey"): compound = [] for c in children: - if c in shapes.keys(): + if c in shapes: compound.append(shapes[c]) del shapes[c] - if c in additions.keys(): + if c in additions: for c2 in additions[c]: - if c2 in shapes.keys(): + if c2 in shapes: compound.append(shapes[c2]) del shapes[c2] if compound: @@ -1054,7 +1054,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): if preferences['SEPARATE_OPENINGS']: for subtraction in subtractions: - if (subtraction[0] in objects.keys()) and (subtraction[1] in objects.keys()): + if (subtraction[0] in objects) and (subtraction[1] in objects): if preferences['DEBUG'] and first: print("") first = False @@ -1065,13 +1065,13 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # additions for host,children in additions.items(): - if host not in objects.keys(): + if host not in objects: # print(host, 'not used') # print(ifcfile[host]) continue cobs = [] for child in children: - if child in objects.keys() \ + if child in objects \ and child not in swallowed: # don't add objects already in groups cobs.append(objects[child]) if not cobs: @@ -1131,11 +1131,11 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None): # placing in container if needed if anno: - if aid in remaining.keys(): + if aid in remaining: remaining[aid].addObject(anno) else: for host,children in additions.items(): - if (aid in children) and (host in objects.keys()): + if (aid in children) and (host in objects): Arch.addComponents(anno,objects[host]) if preferences['DEBUG']: print("") # add newline for 2D objects debug prints diff --git a/src/Mod/Arch/importIFCHelper.py b/src/Mod/Arch/importIFCHelper.py index 9a8f0d479d..024fe78ed1 100644 --- a/src/Mod/Arch/importIFCHelper.py +++ b/src/Mod/Arch/importIFCHelper.py @@ -976,8 +976,8 @@ def createFromProperties(propsets,ifcfile,parametrics): if appset: oname = None otype = None - if "FreeCADType" in appset.keys(): - if "FreeCADName" in appset.keys(): + if "FreeCADType" in appset: + if "FreeCADName" in appset: obj = FreeCAD.ActiveDocument.addObject(appset["FreeCADType"],appset["FreeCADName"]) if "FreeCADAppObject" in appset: mod,cla = appset["FreeCADAppObject"].split(".") diff --git a/src/Mod/Arch/importIFClegacy.py b/src/Mod/Arch/importIFClegacy.py index 8935233f09..5d4c63039f 100644 --- a/src/Mod/Arch/importIFClegacy.py +++ b/src/Mod/Arch/importIFClegacy.py @@ -1017,7 +1017,7 @@ def export(exportList,filename): # getting the "Force BREP" flag brepflag = False if hasattr(obj,"IfcAttributes"): - if "FlagForceBrep" in obj.IfcAttributes.keys(): + if "FlagForceBrep" in obj.IfcAttributes: if obj.IfcAttributes["FlagForceBrep"] == "True": brepflag = True diff --git a/src/Mod/Arch/importSH3D.py b/src/Mod/Arch/importSH3D.py index 98f67998e7..6ae6f9c25e 100644 --- a/src/Mod/Arch/importSH3D.py +++ b/src/Mod/Arch/importSH3D.py @@ -142,7 +142,7 @@ class SH3DHandler(xml.sax.ContentHandler): mat.rotateX(math.pi/2) mat.rotateZ(math.pi) if DEBUG: print("Creating furniture: ",name) - if "angle" in attributes.keys(): + if "angle" in attributes: mat.rotateZ(float(attributes["angle"])) m.transform(mat) os.remove(tf) @@ -186,13 +186,13 @@ class SH3DHandler(xml.sax.ContentHandler): shape = shape.removeSplitter() if shape: if DEBUG: print("Creating window: ",name) - if "angle" in attributes.keys(): + if "angle" in attributes: shape.rotate(shape.BoundBox.Center,FreeCAD.Vector(0,0,1),math.degrees(float(attributes["angle"]))) sub.rotate(shape.BoundBox.Center,FreeCAD.Vector(0,0,1),math.degrees(float(attributes["angle"]))) p = shape.BoundBox.Center.negative() p = p.add(FreeCAD.Vector(float(attributes["x"])*10,float(attributes["y"])*10,0)) p = p.add(FreeCAD.Vector(0,0,shape.BoundBox.Center.z-shape.BoundBox.ZMin)) - if "elevation" in attributes.keys(): + if "elevation" in attributes: p = p.add(FreeCAD.Vector(0,0,float(attributes["elevation"])*10)) shape.translate(p) sub.translate(p)