Advertisement
danfalck

slicing1.py

Dec 1st, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import DraftGeomUtils
  2. import Draft
  3. from FreeCAD import Vector,Base
  4. import math
  5.  
  6.  
  7. def findOutsideWire(wires):
  8.     biggest = wires[0]
  9.     for i in wires:
  10.         if i.BoundBox.DiagonalLength >= biggest.BoundBox.DiagonalLength:
  11.             biggest = i
  12.     return i
  13.  
  14. sel=Gui.Selection.getSelection()
  15. obj = sel[0]
  16. bb = obj.Shape.BoundBox
  17.  
  18. cutterdia = 1.25
  19. offset = cutterdia/2.0
  20. stepdown = 1
  21. zbelow_bottom= -1
  22.  
  23. ztop = bb.ZMax
  24. height = bb.ZMax-bb.ZMin
  25.  
  26. numsteps = int(math.fabs(height/stepdown))
  27. wires=list()
  28. slicelist=[]
  29. z = height-stepdown
  30. for n in range(0,numsteps-1):
  31.     outside = findOutsideWire(obj.Shape.slice(Base.Vector(0,0,1),z))
  32.     outerPath = outside.makeOffset(offset)
  33.     slicelist.append(outerPath)
  34.     z= z-stepdown
  35.  
  36. lastpass = findOutsideWire(obj.Shape.slice(Base.Vector(0,0,1),bb.ZMin+.0001)).makeOffset(offset)
  37. slicelist.append(lastpass)
  38.  
  39. comp=Part.Compound(slicelist)
  40. Part.show(comp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement