Arch: lint bad indentation, superfluous formatting (#9310)
This commit is contained in:
@@ -342,7 +342,7 @@ class AxisSystemTaskPanel:
|
||||
|
||||
if self.obj:
|
||||
for o in FreeCADGui.Selection.getSelection():
|
||||
if (not(o in self.obj.Axes)) and (o != self.obj):
|
||||
if not(o in self.obj.Axes) and (o != self.obj):
|
||||
g = self.obj.Axes
|
||||
g.append(o)
|
||||
self.obj.Axes = g
|
||||
|
||||
@@ -178,33 +178,33 @@ def removeComponents(objectsList,host=None):
|
||||
else:
|
||||
for o in objectsList:
|
||||
if o.InList:
|
||||
h = o.InList[0]
|
||||
tp = Draft.getType(h)
|
||||
if tp in ["Floor","Building","Site","BuildingPart"]:
|
||||
c = h.Group
|
||||
if o in c:
|
||||
c.remove(o)
|
||||
h.Group = c
|
||||
o.ViewObject.show()
|
||||
elif tp in ["Wall","Structure","Precast"]:
|
||||
a = h.Additions
|
||||
s = h.Subtractions
|
||||
if o in a:
|
||||
a.remove(o)
|
||||
h.Additions = a
|
||||
o.ViewObject.show()
|
||||
elif o in s:
|
||||
s.remove(o)
|
||||
h.Subtractions = s
|
||||
o.ViewObject.show()
|
||||
elif o == s.Base:
|
||||
s.Base = None
|
||||
o.ViewObject.show()
|
||||
elif tp in ["SectionPlane"]:
|
||||
a = h.Objects
|
||||
if o in a:
|
||||
a.remove(o)
|
||||
h.Objects = a
|
||||
h = o.InList[0]
|
||||
tp = Draft.getType(h)
|
||||
if tp in ["Floor","Building","Site","BuildingPart"]:
|
||||
c = h.Group
|
||||
if o in c:
|
||||
c.remove(o)
|
||||
h.Group = c
|
||||
o.ViewObject.show()
|
||||
elif tp in ["Wall","Structure","Precast"]:
|
||||
a = h.Additions
|
||||
s = h.Subtractions
|
||||
if o in a:
|
||||
a.remove(o)
|
||||
h.Additions = a
|
||||
o.ViewObject.show()
|
||||
elif o in s:
|
||||
s.remove(o)
|
||||
h.Subtractions = s
|
||||
o.ViewObject.show()
|
||||
elif o == s.Base:
|
||||
s.Base = None
|
||||
o.ViewObject.show()
|
||||
elif tp in ["SectionPlane"]:
|
||||
a = h.Objects
|
||||
if o in a:
|
||||
a.remove(o)
|
||||
h.Objects = a
|
||||
|
||||
def makeComponent(baseobj=None,name="Component",delete=False):
|
||||
'''makeComponent([baseobj]): creates an undefined, non-parametric Arch
|
||||
@@ -638,7 +638,7 @@ def mergeCells(objectslist):
|
||||
return None
|
||||
typ = Draft.getType(objectslist[0])
|
||||
if not(typ in ["Cell","Floor","Building","Site"]):
|
||||
return None
|
||||
return None
|
||||
for o in objectslist:
|
||||
if Draft.getType(o) != typ:
|
||||
return None
|
||||
@@ -1102,7 +1102,7 @@ class SurveyTaskPanel:
|
||||
import csv
|
||||
rows = self.tree.topLevelItemCount()
|
||||
if rows:
|
||||
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
|
||||
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)")
|
||||
if filename:
|
||||
with open(filename[0].encode("utf8"), "w") as csvfile:
|
||||
csvfile = csv.writer(csvfile,delimiter="\t")
|
||||
|
||||
@@ -208,9 +208,9 @@ class Component(ArchIFC.IfcProduct):
|
||||
if not "Material" in pl:
|
||||
obj.addProperty("App::PropertyLink","Material","Component",QT_TRANSLATE_NOOP("App::Property","A material for this object"))
|
||||
if "BaseMaterial" in pl:
|
||||
obj.Material = obj.BaseMaterial
|
||||
obj.removeProperty("BaseMaterial")
|
||||
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" BaseMaterial property to Material\n")
|
||||
obj.Material = obj.BaseMaterial
|
||||
obj.removeProperty("BaseMaterial")
|
||||
FreeCAD.Console.PrintMessage("Upgrading "+obj.Label+" BaseMaterial property to Material\n")
|
||||
if not "MoveBase" in pl:
|
||||
obj.addProperty("App::PropertyBool","MoveBase","Component",QT_TRANSLATE_NOOP("App::Property","Specifies if moving this object moves its base instead"))
|
||||
obj.MoveBase = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("MoveBase",False)
|
||||
@@ -809,18 +809,18 @@ class Component(ArchIFC.IfcProduct):
|
||||
if o.Shape:
|
||||
if not o.Shape.isNull():
|
||||
if o.Shape.Solids and base.Solids:
|
||||
## TODO use Part.Shape() instead?
|
||||
s = o.Shape.copy()
|
||||
if placement:
|
||||
# see https://forum.freecadweb.org/viewtopic.php?p=579754#p579754
|
||||
s.Placement = placement.multiply(s.Placement)
|
||||
try:
|
||||
if len(base.Solids) > 1:
|
||||
base = Part.makeCompound([sol.cut(s) for sol in base.Solids])
|
||||
else:
|
||||
base = base.cut(s)
|
||||
except Part.OCCError:
|
||||
print("Arch: unable to cut object ",o.Name, " from ", obj.Name)
|
||||
## TODO use Part.Shape() instead?
|
||||
s = o.Shape.copy()
|
||||
if placement:
|
||||
# see https://forum.freecadweb.org/viewtopic.php?p=579754#p579754
|
||||
s.Placement = placement.multiply(s.Placement)
|
||||
try:
|
||||
if len(base.Solids) > 1:
|
||||
base = Part.makeCompound([sol.cut(s) for sol in base.Solids])
|
||||
else:
|
||||
base = base.cut(s)
|
||||
except Part.OCCError:
|
||||
print("Arch: unable to cut object ",o.Name, " from ", obj.Name)
|
||||
return base
|
||||
|
||||
def spread(self,obj,shape,placement=None):
|
||||
@@ -1204,10 +1204,10 @@ class ViewProviderComponent:
|
||||
if obj.ViewObject.ShapeColor != c:
|
||||
obj.ViewObject.ShapeColor = c
|
||||
if 'Transparency' in obj.Material.Material:
|
||||
t = int(obj.Material.Material['Transparency'])
|
||||
if obj.ViewObject:
|
||||
if obj.ViewObject.Transparency != t:
|
||||
obj.ViewObject.Transparency = t
|
||||
t = int(obj.Material.Material['Transparency'])
|
||||
if obj.ViewObject:
|
||||
if obj.ViewObject.Transparency != t:
|
||||
obj.ViewObject.Transparency = t
|
||||
elif prop == "Shape":
|
||||
if obj.Base:
|
||||
if obj.Base.isDerivedFrom("Part::Compound"):
|
||||
|
||||
@@ -83,7 +83,7 @@ class _Fence(ArchComponent.Component):
|
||||
|
||||
def __getstate__(self):
|
||||
if hasattr(self, 'sectionFaceNumbers'):
|
||||
return (self.sectionFaceNumbers)
|
||||
return self.sectionFaceNumbers
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -1066,7 +1066,7 @@ class _ViewProviderSite:
|
||||
"""Updates the 'terrain' switches."""
|
||||
|
||||
if not hasattr(self, "terrain_switches"):
|
||||
return
|
||||
return
|
||||
|
||||
idx = 0 if self.Object.Terrain is None else 1
|
||||
for switch in self.terrain_switches:
|
||||
|
||||
@@ -405,12 +405,12 @@ class _Space(ArchComponent.Component):
|
||||
# 3: identifying boundary faces
|
||||
goodfaces = []
|
||||
for b in obj.Boundaries:
|
||||
if hasattr(b[0],'Shape'):
|
||||
for sub in b[1]:
|
||||
if "Face" in sub:
|
||||
fn = int(sub[4:])-1
|
||||
faces.append(b[0].Shape.Faces[fn])
|
||||
#print("adding face ",fn," of object ",b[0].Name)
|
||||
if hasattr(b[0],'Shape'):
|
||||
for sub in b[1]:
|
||||
if "Face" in sub:
|
||||
fn = int(sub[4:])-1
|
||||
faces.append(b[0].Shape.Faces[fn])
|
||||
#print("adding face ",fn," of object ",b[0].Name)
|
||||
|
||||
#print("total: ", len(faces), " faces")
|
||||
|
||||
@@ -669,7 +669,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
if hasattr(self,"font") and hasattr(vobj,"FontName"):
|
||||
self.font.name = str(vobj.FontName)
|
||||
|
||||
elif (prop == "FontSize"):
|
||||
elif prop == "FontSize":
|
||||
if hasattr(self,"font") and hasattr(vobj,"FontSize"):
|
||||
self.font.size = vobj.FontSize.Value
|
||||
if hasattr(vobj,"FirstLine"):
|
||||
@@ -677,7 +677,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
self.header.scaleFactor.setValue([scale,scale,scale])
|
||||
self.onChanged(vobj, "TextPosition")
|
||||
|
||||
elif (prop == "FirstLine"):
|
||||
elif prop == "FirstLine":
|
||||
if hasattr(self,"header") and hasattr(vobj,"FontSize") and hasattr(vobj,"FirstLine"):
|
||||
scale = vobj.FirstLine.Value/vobj.FontSize.Value
|
||||
self.header.scaleFactor.setValue([scale,scale,scale])
|
||||
|
||||
@@ -654,4 +654,3 @@ class Renderer:
|
||||
svg += '"/>\n'
|
||||
svg += '</g>\n'
|
||||
return svg
|
||||
|
||||
|
||||
@@ -1746,12 +1746,12 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
||||
|
||||
def flipDirection(self):
|
||||
|
||||
if hasattr(self,"Object") and self.Object:
|
||||
obj = self.Object
|
||||
if obj.Align == "Left":
|
||||
if hasattr(self,"Object") and self.Object:
|
||||
obj = self.Object
|
||||
if obj.Align == "Left":
|
||||
obj.Align = "Right"
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
elif obj.Align == "Right":
|
||||
elif obj.Align == "Right":
|
||||
obj.Align = "Left"
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
@@ -533,13 +533,13 @@ class _CommandWindow:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
zfile=zipfile.ZipFile(path)
|
||||
files=zfile.namelist()
|
||||
zfile = zipfile.ZipFile(path)
|
||||
files = zfile.namelist()
|
||||
# check for meta-file if it's really a FreeCAD document
|
||||
if files[0] == "Document.xml":
|
||||
image="thumbnails/Thumbnail.png"
|
||||
if image in files:
|
||||
image=zfile.read(image)
|
||||
image = zfile.read(image)
|
||||
thumbfile = tempfile.mkstemp(suffix='.png')[1]
|
||||
thumb = open(thumbfile,"wb")
|
||||
thumb.write(image)
|
||||
|
||||
@@ -285,7 +285,7 @@ def getColors(filename,nodiffuse=False):
|
||||
if ("DiffuseColor" in v) and (not nodiffuse):
|
||||
if len(v["DiffuseColor"]["value"]) == 1:
|
||||
# only one color in DiffuseColor: used for the whole object
|
||||
colors[k] = v["DiffuseColor"]["value"][0]
|
||||
colors[k] = v["DiffuseColor"]["value"][0]
|
||||
else:
|
||||
colors[k] = v["DiffuseColor"]["value"]
|
||||
elif "ShapeColor" in v:
|
||||
|
||||
@@ -1899,7 +1899,7 @@ def getProfile(ifcfile,p):
|
||||
elif isinstance(p.Edges[0].Curve,Part.Ellipse):
|
||||
# extruded ellipse
|
||||
profile = ifcbin.createIfcEllipseProfileDef("AREA",None,pt,p.Edges[0].Curve.MajorRadius,p.Edges[0].Curve.MinorRadius)
|
||||
elif (checkRectangle(p.Edges)):
|
||||
elif checkRectangle(p.Edges):
|
||||
# arbitrarily use the first edge as the rectangle orientation
|
||||
d = vec(p.Edges[0])
|
||||
d.normalize()
|
||||
@@ -2135,7 +2135,7 @@ def getRepresentation(
|
||||
if obj.isDerivedFrom("Part::Feature"):
|
||||
#if hasattr(obj,"Base") and hasattr(obj,"Additions")and hasattr(obj,"Subtractions"):
|
||||
if False: # above is buggy. No way to duplicate shapes that way?
|
||||
if obj.Base and (not obj.Additions) and not(obj.Subtractions):
|
||||
if obj.Base and not obj.Additions and not obj.Subtractions:
|
||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||
if obj.Base.Shape:
|
||||
if obj.Base.Shape.Solids:
|
||||
|
||||
@@ -214,9 +214,9 @@ def createStructuralMember(ifcfile, ifcbin, obj):
|
||||
# creates geometry
|
||||
verts = [None for _ in range(len(edges))]
|
||||
for i, edge in enumerate(edges):
|
||||
verts[i] = tuple(edge.Vertexes[0].Point.multiply(scaling))
|
||||
cartPnt = ifcfile.createIfcCartesianPoint(verts[i])
|
||||
vertPnt = ifcfile.createIfcVertexPoint(cartPnt)
|
||||
verts[i] = tuple(edge.Vertexes[0].Point.multiply(scaling))
|
||||
cartPnt = ifcfile.createIfcCartesianPoint(verts[i])
|
||||
vertPnt = ifcfile.createIfcVertexPoint(cartPnt)
|
||||
orientedEdges = [None for _ in range(len(edges))]
|
||||
for i, vert in enumerate(verts):
|
||||
v2Index = (i + 1) if i < len(verts) - 1 else 0
|
||||
|
||||
@@ -25,8 +25,8 @@ class ifc_object:
|
||||
def __init__(self):
|
||||
pass
|
||||
def onDocumentRestored(self, obj):
|
||||
obj.Type = [obj.IfcType]
|
||||
obj.Type = obj.IfcType
|
||||
obj.Type = [obj.IfcType]
|
||||
obj.Type = obj.IfcType
|
||||
def __getstate__(self):
|
||||
return None
|
||||
def __setstate__(self, state):
|
||||
|
||||
@@ -496,7 +496,3 @@ def export(objectslist,filename):
|
||||
... repeat
|
||||
|
||||
</gbXML>'''
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -610,7 +610,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None):
|
||||
baseobj.Dir = ex[1]
|
||||
if FreeCAD.GuiUp:
|
||||
baseface.ViewObject.hide()
|
||||
if (not baseobj):
|
||||
if not baseobj:
|
||||
baseobj = doc.addObject("Part::Feature",name+"_body")
|
||||
baseobj.Shape = shape
|
||||
else:
|
||||
@@ -921,7 +921,7 @@ def insert(srcfile, docname, skip=[], only=[], root=None, preferences=None):
|
||||
# of the (twodimensional) direction vector for TrueNorth shall be greater than zero.
|
||||
(x, y) = modelRC.TrueNorth.DirectionRatios[:2]
|
||||
obj.Declination = ((math.degrees(math.atan2(y,x))-90+180) % 360)-180
|
||||
if (FreeCAD.GuiUp):
|
||||
if FreeCAD.GuiUp:
|
||||
obj.ViewObject.CompassRotation.Value = obj.Declination
|
||||
|
||||
try:
|
||||
|
||||
@@ -60,9 +60,9 @@ def decode(txt):
|
||||
def findVert(aVertex,aList):
|
||||
"finds aVertex in aList, returns index"
|
||||
for i in range(len(aList)):
|
||||
if ( round(aVertex.X,p) == round(aList[i].X,p) ):
|
||||
if ( round(aVertex.Y,p) == round(aList[i].Y,p) ):
|
||||
if ( round(aVertex.Z,p) == round(aList[i].Z,p) ):
|
||||
if round(aVertex.X,p) == round(aList[i].X,p):
|
||||
if round(aVertex.Y,p) == round(aList[i].Y,p):
|
||||
if round(aVertex.Z,p) == round(aList[i].Z,p):
|
||||
return i
|
||||
return None
|
||||
|
||||
@@ -105,13 +105,13 @@ def getIndices(obj,shape,offsetv,offsetvn):
|
||||
curves = shape.Topology
|
||||
if mesh:
|
||||
for v in mesh.Topology[0]:
|
||||
vlist.append(" "+str(round(v[0],p))+" "+str(round(v[1],p))+" "+str(round(v[2],p)))
|
||||
vlist.append(" "+str(round(v[0],p))+" "+str(round(v[1],p))+" "+str(round(v[2],p)))
|
||||
|
||||
for vn in mesh.Facets:
|
||||
vnlist.append(" "+str(vn.Normal[0]) + " " + str(vn.Normal[1]) + " " + str(vn.Normal[2]))
|
||||
vnlist.append(" "+str(vn.Normal[0]) + " " + str(vn.Normal[1]) + " " + str(vn.Normal[2]))
|
||||
|
||||
for i, vn in enumerate(mesh.Topology[1]):
|
||||
flist.append(" "+str(vn[0]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[1]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[2]+offsetv)+"//"+str(i+offsetvn)+" ")
|
||||
flist.append(" "+str(vn[0]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[1]+offsetv)+"//"+str(i+offsetvn)+" "+str(vn[2]+offsetv)+"//"+str(i+offsetvn)+" ")
|
||||
else:
|
||||
if curves:
|
||||
for v in curves[0]:
|
||||
@@ -126,7 +126,7 @@ def getIndices(obj,shape,offsetv,offsetvn):
|
||||
vlist.append(" "+str(round(v.X,p))+" "+str(round(v.Y,p))+" "+str(round(v.Z,p)))
|
||||
if not shape.Faces:
|
||||
for e in shape.Edges:
|
||||
if DraftGeomUtils.geomType(e) == "Line":
|
||||
if DraftGeomUtils.geomType(e) == "Line":
|
||||
ei = " " + str(findVert(e.Vertexes[0],shape.Vertexes) + offsetv)
|
||||
ei += " " + str(findVert(e.Vertexes[-1],shape.Vertexes) + offsetv)
|
||||
elist.append(ei)
|
||||
@@ -304,7 +304,7 @@ def insert(filename,docname):
|
||||
meshName = ntpath.basename(filename)
|
||||
for i in meshName.split():
|
||||
if "." in i:
|
||||
i = i.split(".")[0]
|
||||
i = i.split(".")[0]
|
||||
meshName = i
|
||||
"called when freecad wants to import a file"
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user