Here is a short demo of Autodesk 123D Make: http://www.youtube.com/watch?feature=pl ... o5TxtKLmjM
It shows a couple different laser cutter friendly ways of breaking down a model:
1) A simple set of stacked layers where each layer is attached to the next.
2) 2 sets of orthogonal layers with spacing in between and slotting to hold them together.
As far as I know there are not currently any tools in FreeCAD for doing either such thing? If this were developed would this sort of tool be considered part of CAM module?
I am playing around with Python scripts and Part.slice methods right now to see what kind of results I can get, slicing objects at arbitrary angles.
Code: Select all
import Part
import sys
from FreeCAD import Base
shape=Part.makeTorus(10,5,Base.Vector(0,0,0),Base.Vector(0,0,1))
def frange(start, end, step):
i = 0
x = start
while x < end:
yield x
i += 1
x = start + i * step
class SlicedShape:
def __init__(self, shape, spacing=0.2, normal=Base.Vector(0,0,1)):
self.shape = shape
self.spacing = spacing
self.normal = Base.Vector(normal)
self.normal.normalize()
self.slices = None
def render(self):
bb = self.shape.BoundBox
points = [
Base.Vector(bb.XMin,bb.YMin,bb.ZMin),
Base.Vector(bb.XMin,bb.YMin,bb.ZMax),
Base.Vector(bb.XMin,bb.YMax,bb.ZMin),
Base.Vector(bb.XMin,bb.YMax,bb.ZMax),
Base.Vector(bb.XMax,bb.YMin,bb.ZMin),
Base.Vector(bb.XMax,bb.YMin,bb.ZMax),
Base.Vector(bb.XMax,bb.YMax,bb.ZMin),
Base.Vector(bb.XMax,bb.YMax,bb.ZMax)
]
dmax = sys.float_info.min
dmin = sys.float_info.max
origin = Base.Vector(0,0,0)
for point in points:
d = point.distanceToPlane(origin, self.normal)
if d > dmax:
dmaxPoint = point
dmax = d
if d < dmin:
dminPoint = point
dmin = d
print "Bounds x1:%f y1:%f z1:%f x2:%f y2:%f z2:%f" % (bb.XMin, bb.YMin, bb.ZMin, bb.XMax, bb.YMax, bb.ZMax)
print "Min: %f, Max: %f" % (dmin, dmax)
# display the max and min point being used
Part.show(Part.makeSphere(0.1, dmaxPoint))
Part.show(Part.makeSphere(0.1, dminPoint))
# display the line over which the slicing plane will iterate
n = self.normal
maxPoint = (n.x * dmax, n.y * dmax, n.z * dmax)
minPoint = (n.x * dmin, n.y * dmin, n.z * dmin)
Part.show(Part.makeLine(minPoint, maxPoint))
if self.slices is not None:
#TODO remove old slices if some already displayed
pass
# redundant slicing to print which offsets are returning wires or not
for offset in frange(dmin, dmax, self.spacing):
slice = self.shape.slice(self.normal, offset)
print offset, slice
# slice for display
slices = self.shape.slices(self.normal, [x for x in frange(dmin, dmax, self.spacing)])
Part.show(slices)
self.slices = slices
s = SlicedShape(shape, normal=Base.Vector(0, 1, 1))
Part.show(shape)
s.render()
Seems like there are some bugs in the Part.slice method?