Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import FreeCAD,FreeCADGui,Part
- sel = FreeCADGui.Selection.getSelection()
- for o in sel:
- obj = o.Shape
- #find highest bounding boxes
- zmax = 0.0
- for w in obj.Wires:
- if w.BoundBox.ZMax >= zmax:
- zmax = w.BoundBox.ZMax
- print "Zmax = " + str(zmax)
- #make list of highest wires
- topwires = []
- for w in obj.Wires:
- if (w.BoundBox.ZMax == zmax) and (w.BoundBox.ZMin == zmax):
- topwires.append(w)
- print len(topwires)
- #find largest wire -most likely on outside
- outside = topwires[0]
- biggest = topwires[0].BoundBox.DiagonalLength
- inside = []
- for t in topwires:
- if t.BoundBox.DiagonalLength >= biggest:
- biggest = t.BoundBox.DiagonalLength
- outside = t
- else:
- inside.append(t)
- print outside.BoundBox.DiagonalLength
- for i in inside:
- print i.BoundBox.DiagonalLength
- ######################################################
- sel = FreeCADGui.Selection.getSelection()
- for o in sel:
- obj = o.Shape
- Ztop = obj.BoundBox.ZMax
- Zbottom = obj.BoundBox.ZMin
- wires = obj.Wires
- outside = wires[0]
- biggest = wires[0].BoundBox.DiagonalLength
- inside = []
- for w in wires:
- #acquire largest profile
- if w.BoundBox.DiagonalLength >= biggest:
- biggest = w.BoundBox.DiagonalLength
- outside = w
- #make list of inside profiles that are not lines going straight up and down
- else:
- if (w.BoundBox.ZMin <> Zbottom):
- if (w.BoundBox.ZMax <> w.BoundBox.ZMin) :
- pass
- else:
- inside.append(w)
- print outside.BoundBox.DiagonalLength
- for d in inside:
- print d.BoundBox.DiagonalLength
- sel = FreeCADGui.Selection.getSelection()
- for o in sel:
- obj = o.Shape
- #find faces that are on outside profile with fillets
- faces = obj.Faces
- outerwires = []
- facelist = []
- for f in faces:
- if f.BoundBox.ZLength >= .0001:
- print "ZMax: "+str(f.BoundBox.ZMax)+" ZMin: "+str(f.BoundBox.ZMin)+" ZLen: "+str(f.BoundBox.ZLength)
- facelist.append(f)
- print len(obj.Faces)
- print len(facelist)
- Ztop = obj.BoundBox.ZMax
- wirelist = []
- for f in facelist:
- print f.BoundBox
- import Part
- from FreeCAD import Base, Vector
- import FreeCAD,FreeCADGui,Part
- sel = FreeCADGui.Selection.getSelection()
- for o in sel:
- obj = o.Shape
- Zlevel = (obj.BoundBox.ZMax-obj.BoundBox.ZMin)/2.0
- wires = obj.slice(Base.Vector(0,0,1),Zlevel)
- comp=Part.Compound(wires)
- slice=FreeCAD.getDocument("freecad_blob_for_cnc").addObject("Part::Feature","Milled Edges")
- slice.Shape=comp
- outside = slice.Shape.Wires[0]
- biggest = slice.Shape.Wires[0].BoundBox.DiagonalLength
- inside = []
- for t in slice.Shape.Wires:
- if t.BoundBox.DiagonalLength >= biggest:
- biggest = t.BoundBox.DiagonalLength
- outside = t
- else:
- inside.append(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement