def LoadSurface(fn, workplane): fssurf = fsp.FsSurf.New() # surface object # read STL file and call PushTriangle (method in fssurf) for each triangle r = STLTools.reader(fn) if workplane: fs = STLTools.FacetTrans(workplane, fssurf) else: fs = fssurf fl = open(fn, r.isascii and "r" or "rb") try: if r.isascii: r.AsciiReadFacets(fl, fs) else: r.BinaryReadFacets(fl, fs) except: sys.stderr.write("Failed to read STL file: %s" % fn) fl.close() return fl.close() fssurf.Build(1.0) # build surface boxing return fssurf
def __init__(self, fssurf, workplane): if workplane: self.fs = STLTools.FacetTrans(workplane, fssurf) else: self.fs = fssurf self.trialist = []