Code: Select all
doc = App.ActiveDocument
obj = doc.getObject("IsoCurve")
ob, fa = obj.Face
face = getattr(ob.Shape, fa[0])
surf = face.Surface
umin, umax, vmin, vmax = sub.ParameterRange
nu = obj.NumberU
ulist = [i*(umax - umin)/nu + umin for i in range(nu+1)]
nv = obj.NumberV
vlist = [i*(vmax - vmin)/nv + vmin for i in range(nv+1)]
boxLength = 2
cmpd = doc.addObject("Part::Compound","CompoundBoxes")
links = []
for u in ulist:
for v in vlist:
base = surf.value(u, v)
normal = surf.normal(u,v)
rot = App.Rotation(App.Vector(0,0,1), normal)
box = Part.makeBox(boxLength, boxLength, boxLength)
centerpl = App.Placement(-(boxLength/2) * App.Vector(1,1,1), App.Rotation())
box.Placement = App.Placement(base, rot) * centerpl
boxdoc = Part.show(box, 'Box')
links.append(boxdoc)
cmpd.Links = links
doc.recompute()