Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
py3: Arch: *.py: Fix syntax for python3
  • Loading branch information
plaes authored and looooo committed Jan 17, 2017
1 parent 9876307 commit 1591601
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 291 deletions.
36 changes: 18 additions & 18 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -293,7 +293,7 @@ def splitMesh(obj,mark=True):

def makeFace(wires,method=2,cleanup=False):
'''makeFace(wires): makes a face from a list of wires, finding which ones are holes'''
#print "makeFace: start:", wires
#print("makeFace: start:", wires)
import Part

if not isinstance(wires,list):
Expand All @@ -308,44 +308,44 @@ def makeFace(wires,method=2,cleanup=False):

wires = wires[:]

#print "makeFace: inner wires found"
#print("makeFace: inner wires found")
ext = None
max_length = 0
# cleaning up rubbish in wires
if cleanup:
for i in range(len(wires)):
wires[i] = DraftGeomUtils.removeInterVertices(wires[i])
#print "makeFace: garbage removed"
#print("makeFace: garbage removed")
for w in wires:
# we assume that the exterior boundary is that one with
# the biggest bounding box
if w.BoundBox.DiagonalLength > max_length:
max_length = w.BoundBox.DiagonalLength
ext = w
#print "makeFace: exterior wire",ext
#print("makeFace: exterior wire", ext)
wires.remove(ext)

if method == 1:
# method 1: reverse inner wires
# all interior wires mark a hole and must reverse
# their orientation, otherwise Part.Face fails
for w in wires:
#print "makeFace: reversing",w
#print("makeFace: reversing", w)
w.reverse()
# make sure that the exterior wires comes as first in the list
wires.insert(0, ext)
#print "makeFace: done sorting", wires
#print("makeFace: done sorting", wires)
if wires:
return Part.Face(wires)
else:
# method 2: use the cut method
mf = Part.Face(ext)
#print "makeFace: external face:",mf
#print("makeFace: external face:", mf)
for w in wires:
f = Part.Face(w)
#print "makeFace: internal face:",f
#print("makeFace: internal face:", f)
mf = mf.cut(f)
#print "makeFace: final face:",mf.Faces
#print("makeFace: final face:", mf.Faces)
return mf.Faces[0]

def closeHole(shape):
Expand Down Expand Up @@ -475,7 +475,7 @@ def getShapeFromMesh(mesh,fast=True,tolerance=0.001,flat=False,cut=True):
# print "getShapeFromMesh: non-solid mesh, using slow method"
faces = []
segments = mesh.getPlanarSegments(tolerance)
#print len(segments)
#print(len(segments))
for i in segments:
if len(i) > 0:
wires = MeshPart.wireFromSegment(mesh, i)
Expand Down Expand Up @@ -581,7 +581,7 @@ def removeShape(objs,mark=True):
if dims:
name = obj.Name
tp = Draft.getType(obj)
print tp
print(tp)
if tp == "Structure":
FreeCAD.ActiveDocument.removeObject(name)
import ArchStructure
Expand Down Expand Up @@ -900,7 +900,7 @@ def makeCompoundFromSelected(objects=None):
Part.show(c)


def cleanArchSplitter(objets=None):
def cleanArchSplitter(objecs=None):
"""cleanArchSplitter([objects]): removes the splitters from the base shapes
of the given Arch objects or selected Arch objects if objects is None"""
import FreeCAD,FreeCADGui
Expand All @@ -912,7 +912,7 @@ def cleanArchSplitter(objets=None):
if obj.isDerivedFrom("Part::Feature"):
if hasattr(obj,"Base"):
if obj.Base:
print "Attempting to clean splitters from ",obj.Label
print("Attempting to clean splitters from ", obj.Label)
if obj.Base.isDerivedFrom("Part::Feature"):
if not obj.Base.Shape.isNull():
obj.Base.Shape = obj.Base.Shape.removeSplitter()
Expand All @@ -933,31 +933,31 @@ def rebuildArchShape(objects=None):
if hasattr(obj,"Base"):
if obj.Base:
try:
print "Attempting to rebuild ",obj.Label
print("Attempting to rebuild ", obj.Label)
if obj.Base.isDerivedFrom("Part::Feature"):
if not obj.Base.Shape.isNull():
faces = []
for f in obj.Base.Shape.Faces:
f2 = Part.Face(f.Wires)
#print "rebuilt face: isValid is ",f2.isValid()
#print("rebuilt face: isValid is ", f2.isValid())
faces.append(f2)
if faces:
shell = Part.Shell(faces)
if shell:
#print "rebuilt shell: isValid is ",shell.isValid()
#print("rebuilt shell: isValid is ", shell.isValid())
solid = Part.Solid(shell)
if solid:
if not solid.isValid():
solid.sewShape()
solid = Part.Solid(solid)
#print "rebuilt solid: isValid is ",solid.isValid()
#print("rebuilt solid: isValid is ",solid.isValid())
if solid.isValid():
obj.Base.Shape = solid
success = True
except:
pass
if not success:
print "Failed to rebuild a valid solid for object ",obj.Name
print ("Failed to rebuild a valid solid for object ",obj.Name)
FreeCAD.ActiveDocument.recompute()


Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Arch/ArchComponent.py
Expand Up @@ -470,7 +470,7 @@ def hideSubobjects(self,obj,prop):
def processSubShapes(self,obj,base,placement=None):
"Adds additions and subtractions to a base shape"
import Draft,Part
#print "Processing subshapes of ",obj.Label, " : ",obj.Additions
#print("Processing subshapes of ",obj.Label, " : ",obj.Additions)

if placement:
if placement.isNull():
Expand Down Expand Up @@ -520,7 +520,7 @@ def processSubShapes(self,obj,base,placement=None):
try:
base = base.fuse(s)
except Part.OCCError:
print "Arch: unable to fuse object ",obj.Name, " with ", o.Name
print("Arch: unable to fuse object ", obj.Name, " with ", o.Name)
else:
base = s

Expand Down Expand Up @@ -558,7 +558,7 @@ def processSubShapes(self,obj,base,placement=None):
try:
base = base.cut(s)
except Part.OCCError:
print "Arch: unable to cut object ",o.Name, " from ", obj.Name
print("Arch: unable to cut object ",o.Name, " from ", obj.Name)
return base

def applyShape(self,obj,shape,placement,allowinvalid=False,allownosolid=False):
Expand Down Expand Up @@ -659,7 +659,7 @@ def __init__(self,vobj):
self.Object = vobj.Object

def updateData(self,obj,prop):
#print obj.Name," : updating ",prop
#print(obj.Name," : updating ",prop)
if prop == "BaseMaterial":
if obj.BaseMaterial:
if 'DiffuseColor' in obj.BaseMaterial.Material:
Expand Down Expand Up @@ -692,7 +692,7 @@ def getIcon(self):
return ":/icons/Arch_Component.svg"

def onChanged(self,vobj,prop):
#print vobj.Object.Name, " : changing ",prop
#print(vobj.Object.Name, " : changing ",prop)
if prop == "Visibility":
#for obj in vobj.Object.Additions+vobj.Object.Subtractions:
# if (Draft.getType(obj) == "Window") or (Draft.isClone(obj,"Window",True)):
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchEquipment.py
Expand Up @@ -165,7 +165,7 @@ def createMeshView(obj,direction=FreeCAD.Vector(0,0,-1),outeronly=False,largesto
try:
f = Part.Face(w)
except Part.OCCError:
print "Unable to produce a face from the outer wire."
print("Unable to produce a face from the outer wire.")
else:
shape = f

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchFloor.py
Expand Up @@ -147,7 +147,7 @@ def execute(self,obj):
else:
pl = obj.Placement.copy()
if not DraftVecUtils.equals(pl.Base,self.OldPlacement.Base):
print "placement moved"
print("placement moved")
delta = pl.Base.sub(self.OldPlacement.Base)
for o in obj.Group:
if hasattr(o,"Placement"):
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Arch/ArchProfile.py
Expand Up @@ -73,9 +73,9 @@ def readPresets():
Presets.append(r)
bid=bid+1
except ValueError:
print "Skipping bad line: "+str(row)
print("Skipping bad line: "+str(row))
except IOError:
print "Could not open ",profilefile
print("Could not open ",profilefile)
return Presets

def makeProfile(profile=[0,'REC','REC100x100','R',100,100]):
Expand All @@ -93,7 +93,7 @@ def makeProfile(profile=[0,'REC','REC100x100','R',100,100]):
elif profile[3]=="U":
_ProfileU(obj, profile)
else :
print "Profile not supported"
print("Profile not supported")
if FreeCAD.GuiUp:
Draft._ViewProviderDraft(obj.ViewObject)
return obj
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Arch/ArchRebar.py
Expand Up @@ -145,7 +145,7 @@ def Activated(self):
FreeCAD.ActiveDocument.recompute()
return
else:
print "Arch: error: couldn't extract a base object"
print("Arch: error: couldn't extract a base object")
return

FreeCAD.Console.PrintMessage(translate("Arch","Please select a base face on a structural object\n"))
Expand Down Expand Up @@ -208,7 +208,7 @@ def execute(self,obj):
father = obj.InList[0]
wire = obj.Base.Shape.Wires[0]
if hasattr(obj,"Rounding"):
#print obj.Rounding
#print(obj.Rounding)
if obj.Rounding:
radius = obj.Rounding * obj.Diameter.Value
import DraftGeomUtils
Expand All @@ -223,8 +223,8 @@ def execute(self,obj):
axis = FreeCAD.Vector(obj.Direction) #.normalize()
# don't normalize so the vector can also be used to determine the distance
size = axis.Length
#print axis
#print size
#print(axis)
#print(size)
if (obj.OffsetStart.Value + obj.OffsetEnd.Value) > size:
return

Expand All @@ -236,7 +236,7 @@ def execute(self,obj):
try:
bar = wire.makePipeShell([circle],True,False,2)
except Part.OCCError:
print "Arch: error sweeping rebar profile along the base sketch"
print("Arch: error sweeping rebar profile along the base sketch")
return
# building final shape
shapes = []
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchSectionPlane.py
Expand Up @@ -622,7 +622,7 @@ def setDisplayMode(self,mode):
def getDXF(self,obj):
"returns a DXF representation of the view"
if obj.RenderingMode == "Solid":
print "Unable to get DXF from Solid mode: ",obj.Label
print("Unable to get DXF from Solid mode: ",obj.Label)
return ""
result = []
import Drawing
Expand Down
18 changes: 9 additions & 9 deletions src/Mod/Arch/ArchSpace.py
Expand Up @@ -312,7 +312,7 @@ def getShape(self,obj):
shape = None
faces = []

#print "starting compute"
#print("starting compute")
# 1: if we have a base shape, we use it

if obj.Base:
Expand All @@ -323,7 +323,7 @@ def getShape(self,obj):

# 2: if not, add all bounding boxes of considered objects and build a first shape
if shape:
#print "got shape from base object"
#print("got shape from base object")
bb = shape.BoundBox
else:
bb = None
Expand All @@ -336,7 +336,7 @@ def getShape(self,obj):
if not bb:
return
shape = Part.makeBox(bb.XLength,bb.YLength,bb.ZLength,FreeCAD.Vector(bb.XMin,bb.YMin,bb.ZMin))
#print "created shape from boundbox"
#print("created shape from boundbox")

# 3: identifing boundary faces
goodfaces = []
Expand All @@ -345,9 +345,9 @@ def getShape(self,obj):
if "Face" in b[1]:
fn = int(b[1][4:])-1
faces.append(b[0].Shape.Faces[fn])
#print "adding face ",fn," of object ",b[0].Name
#print("adding face ",fn," of object ",b[0].Name)

#print "total: ", len(faces), " faces"
#print("total: ", len(faces), " faces")

# 4: get cutvolumes from faces
cutvolumes = []
Expand All @@ -356,22 +356,22 @@ def getShape(self,obj):
f.reverse()
cutface,cutvolume,invcutvolume = ArchCommands.getCutVolume(f,shape)
if cutvolume:
#print "generated 1 cutvolume"
#print("generated 1 cutvolume")
cutvolumes.append(cutvolume.copy())
#Part.show(cutvolume)
for v in cutvolumes:
#print "cutting"
#print("cutting")
shape = shape.cut(v)

# 5: get the final shape
if shape:
if shape.Solids:
#print "setting objects shape"
#print("setting objects shape")
shape = shape.Solids[0]
obj.Shape = shape
return

print "Arch: error computing space boundary"
print("Arch: error computing space boundary")

def getArea(self,obj):
"returns the horizontal area at the center of the space"
Expand Down
12 changes: 6 additions & 6 deletions src/Mod/Arch/ArchStairs.py
Expand Up @@ -258,7 +258,7 @@ def makeStraightLanding(self,obj,edge,numberofsteps=None):
fLength = float(l-obj.Width.Value)/(numberofsteps-2)
fHeight = float(h)/numberofsteps
a = math.atan(fHeight/fLength)
print "landing data:",fLength,":",fHeight
print("landing data:",fLength,":",fHeight)

# step
p1 = self.align(vBase,obj.Align,vWidth)
Expand Down Expand Up @@ -365,7 +365,7 @@ def makeStraightStairs(self,obj,edge,numberofsteps=None):
vBase = edge.Vertexes[0].Point
vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value))
a = math.atan(vHeight.Length/vLength.Length)
#print "stair data:",vLength.Length,":",vHeight.Length
#print("stair data:",vLength.Length,":",vHeight.Length)

# steps
for i in range(numberofsteps-1):
Expand Down Expand Up @@ -402,7 +402,7 @@ def makeStraightStairs(self,obj,edge,numberofsteps=None):
h = DraftVecUtils.scaleTo(vLength,-resLength)
lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2)))
lProfile.append(vBase)
#print lProfile
#print(lProfile)
pol = Part.makePolygon(lProfile)
struct = Part.Face(pol)
evec = vWidth
Expand All @@ -429,7 +429,7 @@ def makeStraightStairs(self,obj,edge,numberofsteps=None):
v4 = DraftVecUtils.scaleTo(vLength,-l4)
lProfile.append(lProfile[-1].add(v4))
lProfile.append(lProfile[0])
#print lProfile
#print(lProfile)
pol = Part.makePolygon(lProfile)
pol = Part.Face(pol)
evec = DraftVecUtils.scaleTo(vWidth,obj.StringerWidth.Value)
Expand Down Expand Up @@ -484,10 +484,10 @@ def makeStraightStairsWithLanding(self,obj,edge):


def makeCurvedStairs(self,obj,edge):
print "Not yet implemented!"
print("Not yet implemented!")

def makeCurvedStairsWithLanding(self,obj,edge):
print "Not yet implemented!"
print("Not yet implemented!")



Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchStructure.py
Expand Up @@ -103,7 +103,7 @@ def makeStructuralSystem(objects=[],axes=[],name="StructuralSystem"):
based on the given objects and axes'''
result = []
if not axes:
print "At least one axis must be given"
print("At least one axis must be given")
return
if objects:
if not isinstance(objects,list):
Expand Down

0 comments on commit 1591601

Please sign in to comment.