#!/usr/bin/env python # duck generator import math from math import pi import stlwrite import csg def frange(x, maximum, step): while x < maximum: yield x x += step def get_ellipsoid(A,B,C,x0,y0,z0): " You fill in this code " return faces def get_duck_features(): """Return a list of body parts. Each body part is a list of faces (quads or triangles) generated by get_ellipsoid(). So the result is a list of lists of faces. """ # You fill in this part return body_parts def write_simple_duck(): parts = get_duck_features() # Put all the faces together in one big list. faces = [] for part in parts: faces.extend(part) # Write the list as an STL file filename = "simple_duck.stl" with open(filename, 'wb') as fp: writer = stlwrite.ASCII_STL_Writer(fp) writer.add_faces(faces) writer.close() print("Wrote " + filename) def write_good_duck(): filename = "duck_union.stl" # Do a mesh union of all the body parts body_parts = get_duck_features() good_mesh = csg.union_all(body_parts) good_mesh.saveSTL(filename, binary=False)

AltStyle によって変換されたページ (->オリジナル) /