Esempio n. 1
0
def save_stl():
    """Save the stl model."""
    global project,F
    if F is None:
        return
    fn = askFilename(GD.cfg['workdir'],"Stl files (*.stl)",exist=False)
    if fn:
        if not fn.endswith('.stl'):
            fn += '.stl'
        os.chdir(os.path.dirname(fn))
        message("Your current workdir is %s" % os.getcwd())
        project = os.path.splitext(fn)[0]
        if not os.path.exists(fn) or ack("File %s already exists. Overwrite?" % fn):
            stl.write_ascii(F.f,fn)
Esempio n. 2
0
#create a bottom
b = e.reverseElements()

for p in a:
    e = e.bump(2,p, lambda x:exp(-0.5*x),[0,1])

draw (e,color=red)

if ack('Shrink the elements?'):
    clear()
    draw(e.shrink(0.8))

if ack('Export to .stl?'):
    from plugins import stl
    f = file('novation.stl','w')
    F = e # + b
    # Create triangles
    G = F.selectNodes([0,1,2])
    # If polygones, add more triangles
    for i in range(3,F.nplex()):
        G += F.selectNodes([0,i-1,i])
    clear()
    draw(G)
    stl.write_ascii(G.f,f)
    f.close()

if ack('Show with smooth rendering?'):
    clear()
    smooth()
    draw(e)
for i,f in enumerate(F[1:]):
    G[0].append(connect([F[i],f,f],bias=[0,1,0]))
    if i > 0:
        G[1].append(connect([F[i],F[i],f],bias=[0,1,1]))
G = map(Formex.concatenate,G)
for i,f in enumerate(G):
    f.setProp(i)
G = Formex.concatenate(G)

clear()
draw(G)

flat()
GD.canvas.update()
T = G.translate([0,bot,r]).spherical()
clear()
draw(T)

T += T.reflect()
clear()
draw(T)

if ack('Export this model in STL format?'):
    fn = askFilename(GD.cfg['workdir'],"Stl files (*.stl)",exist=False)
    if fn:
        from plugins import stl
        f = file(fn,'w')
        stl.write_ascii(T.f,f)
        f.close()

##for i,f in enumerate(F[1:]):
##    G[0].append(connect([F[i],f,f],bias=[0,1,0]))
##    if i > 0:
##        G[1].append(connect([F[i],F[i],f],bias=[0,1,1]))
##G = map(Formex.concatenate,G)
##for i,f in enumerate(G):
##    f.setProp(i)
##G = Formex.concatenate(G)

##clear()
##draw(G)

##flat()
##GD.canvas.update()
##T = G.translate([0,bot,r]).spherical()
##clear()
##draw(T)

##T += T.reflect()
##clear()
##draw(T)

if ack('Export this model in STL format?'):
    fn = askFilename(GD.cfg['workdir'],"Stl files (*.stl)",exist=False)
    if fn:
        from plugins import stl
        f = file(fn,'w')
        stl.write_ascii(f,T.f)
        f.close()