Skip to content

Commit

Permalink
first step to py compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
easyw committed Aug 27, 2018
1 parent 693caf7 commit 586fbeb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
38 changes: 19 additions & 19 deletions SheetMetalCmd.py
Expand Up @@ -441,25 +441,25 @@ def update(self):
self.retranslateUi(self.form)

def updateElement(self):
if self.obj:
sel = FreeCADGui.Selection.getSelectionEx()[0]
if sel.HasSubObjects:
obj = sel.Object
for elt in sel.SubElementNames:
if "Face" in elt:
face = self.obj.baseObject
found = False
if (face[0] == obj.Name):
if isinstance(face[1],tuple):
for subf in face[1]:
if subf == elt:
found = True
else:
if (face[1][0] == elt):
found = True
if not found:
self.obj.baseObject = (sel.Object, sel.SubElementNames)
self.update()
if self.obj:
sel = FreeCADGui.Selection.getSelectionEx()[0]
if sel.HasSubObjects:
obj = sel.Object
for elt in sel.SubElementNames:
if "Face" in elt:
face = self.obj.baseObject
found = False
if (face[0] == obj.Name):
if isinstance(face[1],tuple):
for subf in face[1]:
if subf == elt:
found = True
else:
if (face[1][0] == elt):
found = True
if not found:
self.obj.baseObject = (sel.Object, sel.SubElementNames)
self.update()

def accept(self):
FreeCAD.ActiveDocument.recompute()
Expand Down
24 changes: 12 additions & 12 deletions SheetMetalUnfolder.py
Expand Up @@ -648,7 +648,7 @@ def cutEdgeFace(self, eIdx, fIdx, theEdge, theNode):

maxDistance = 1000
oppoPoint = None
print 'need to check Face', str(fIdx+1), ' with ', len(self.f_list[fIdx].Vertexes)
print ('need to check Face', str(fIdx+1), ' with ', len(self.f_list[fIdx].Vertexes))
for theVert in self.f_list[fIdx].Vertexes:
# need to check if theVert has
if self.isVertOpposite(theVert, theNode):
Expand All @@ -658,7 +658,7 @@ def cutEdgeFace(self, eIdx, fIdx, theEdge, theNode):
oppoPoint = theVert.Point

if oppoPoint is None:
print ' error need always an opposite point in a side face!'
print (' error need always an opposite point in a side face!')
# fix me: need a proper error condition.

#vec1 = Base.Vector(theNode.axis.x, theNode.axis.y, theNode.axis.z) # make a copy
Expand Down Expand Up @@ -698,7 +698,7 @@ def cutEdgeFace(self, eIdx, fIdx, theEdge, theNode):

maxDistance = 1000
oppoPoint = None
print 'need to check Face', str(fIdx+1), ' with ', len(self.f_list[fIdx].Vertexes)
print ('need to check Face', str(fIdx+1), ' with ', len(self.f_list[fIdx].Vertexes))
for theVert in self.f_list[fIdx].Vertexes:
# need to check if theVert has
if self.isVertOpposite(theVert, theNode):
Expand All @@ -708,7 +708,7 @@ def cutEdgeFace(self, eIdx, fIdx, theEdge, theNode):
oppoPoint = theVert.Point

if oppoPoint is None:
print ' error need always an opposite point in a side face!'
print (' error need always an opposite point in a side face!')
# fix me: need a proper error condition.
#vec1 = Base.Vector(radVector.x, radVector.y, radVector.z) # make a copy
vec1 = (oppoPoint - origin).normalize()
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def make_new_face_node(self, face_idx, P_node, P_edge, wires_e_lists):
flagStr = flagStr + 'p1'
origVec = P_edge.Vertexes[1].Point
unbendVec = origVec
print 'make vertexDict: ', flagStr, ' ', str(face_idx+1)
print ('make vertexDict: ', flagStr, ' ', str(face_idx+1))
newNode.vertexDict[vertDictIdx] = flagStr, origVec, unbendVec
vertDictIdx += 1

Expand All @@ -1149,7 +1149,7 @@ def make_new_face_node(self, face_idx, P_node, P_edge, wires_e_lists):
flagStr = flagStr + 'p'
origVec = pVert.Point
unbendVec = origVec
print 'make vertexDict: ', flagStr, ' ', str(face_idx+1)
print ('make vertexDict: ', flagStr, ' ', str(face_idx+1))
newNode.vertexDict[vertDictIdx] = flagStr, origVec, unbendVec
vertDictIdx += 1

Expand Down Expand Up @@ -1254,7 +1254,7 @@ def searchNode(self, theIdx, sNode):
if nextSearch is not None:
result = nextSearch
break
if result<>None:
if result is not None:
FreeCAD.Console.PrintLog("This is the result: "+ str(result.idx) + "\n")
else:
FreeCAD.Console.PrintLog("This is the result: None\n")
Expand Down Expand Up @@ -1335,7 +1335,7 @@ def unbendPoint(poi):
for aWire in fWireList:
uEdge = None
idxList, closedW = self.sortEdgesTolerant(aWire.Edges)
print 'Wire', str(fIdx+1), ' has ', len(idxList), ' edges, closed: ', closedW
print ('Wire', str(fIdx+1), ' has ', len(idxList), ' edges, closed: ', closedW)

eList = [] # is the list of unbend edges
j=0
Expand Down Expand Up @@ -1372,15 +1372,15 @@ def unbendPoint(poi):
if mode == 'side':
if vert0Idx is None:
vert0Idx = len(bend_node.vertexDict)
print 'got additional side vertex0: ', vert0Idx, ' ', fEdge.Vertexes[0].Point
print ('got additional side vertex0: ', vert0Idx, ' ', fEdge.Vertexes[0].Point)
flags0 = ''
origVec = fEdge.Vertexes[0].Point
uVert0 = unbendPoint(origVec)
bend_node.vertexDict[vert0Idx] = flags0, origVec, uVert0
if vertexCount >1:
if vert1Idx is None:
vert1Idx = len(bend_node.vertexDict)
print 'got additional side vertex1: ', vert1Idx, ' ', fEdge.Vertexes[1].Point
print ('got additional side vertex1: ', vert1Idx, ' ', fEdge.Vertexes[1].Point)
flags1 = ''
origVec = fEdge.Vertexes[1].Point
uVert1 = unbendPoint(origVec)
Expand Down Expand Up @@ -1616,7 +1616,7 @@ def unbendPoint(poi):
except:
#theFace = Part.makeFilledFace(wires)
theFace = faces[0]
print 'got execption'
print ('got execption')
#Part.show(theFace, 'exception')
keyList = []
for key in bend_node.edgeDict:
Expand Down Expand Up @@ -1736,7 +1736,7 @@ def makeFoldLines(self, bend_node, nullVec):
wireList.append(edgeL)
#Part.show(lWire, 'foldLine'+str(bend_node.idx +1)+'_')
else:
print 'fix me! make errorcondition'
print ('fix me! make errorcondition')

return wireList

Expand Down

0 comments on commit 586fbeb

Please sign in to comment.