{ "nodes": [ { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "1", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXqYf1',float('-1.000000'),float('-1.000000'),float('-inf'),float('1.000000'),float('1.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -694.92339215345714, -287.60281932577425 ], "name": "base", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 1 }, { "datums": [ { "expr": "base.x0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "base.y0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "base.r * 1.9", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXqYf1.9',float('-1.900000'),float('-1.900000'),float('-inf'),float('1.900000'),float('1.900000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -693.77345595731981, -76.151833885642787 ], "name": "base2", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__2.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "1", "name": "z0", "type": "float", "uid": 1 }, { "expr": "\u0011[__1.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 2 }, { "expr": "2", "name": "z1", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-Zf2-f1Z/+*-Zf1-r+qXqYf1*-f2Z-r+qXqYf1.9f1',float('-1.900000'),float('-1.900000'),float('1.000000'),float('1.900000'),float('1.900000'),float('2.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -331.27820341449853, -119.81612598070063 ], "name": "baseloft", "script": [ "# Neil Gershenfeld 2/1/15", "# Matt Keeter 6/13/15", "", "import fab", "", "title('Loft')", "", "input('a', fab.types.Shape)", "input('z0', float)", "input('b', fab.types.Shape)", "input('z1', float)", "", "output('out', fab.shapes.loft_xy_z(a, b, z0, z1))", "", "" ], "uid": 0 }, { "datums": [ { "expr": "base2.x0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "base2.y0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "base2.r * 1.4", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXqYf2.66',float('-2.660000'),float('-2.660000'),float('-inf'),float('2.660000'),float('2.660000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -695.9483710984523, 128.62013026739135 ], "name": "base3", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 3 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 1 }, { "expr": "0", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "1", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__3.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXqYf2.66a-f0Z-Zf1',float('-2.660000'),float('-2.660000'),float('0.000000'),float('2.660000'),float('2.660000'),float('1.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -330.71698991526489, 130.77773446690651 ], "name": "base3extrude", "script": [ "import fab", "", "title('Extrude')", "", "input('_x', float)", "input('_y', float)", "input('zmin', float)", "input('zmax', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.extrude_z(shape, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(_x, _y, zmin), (_x, _y, zmax)], color=sb.color.green)", "sb.ui.point(_x, _y, zmin, color=sb.color.green)", "sb.ui.point(_x, _y, zmax, color=sb.color.green)", "", "" ], "uid": 4 }, { "datums": [ { "expr": "base.x0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "base.y0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "base.r", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXqYf1',float('-1.000000'),float('-1.000000'),float('-inf'),float('1.000000'),float('1.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -693.31741142055159, 337.14160992166177 ], "name": "shaft", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 5 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 1 }, { "expr": "2", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "5", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__5.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXqYf1a-f2Z-Zf5',float('-1.000000'),float('-1.000000'),float('2.000000'),float('1.000000'),float('1.000000'),float('5.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -371.67206822577748, 324.29215293251559 ], "name": "e1", "script": [ "import fab", "", "title('Extrude')", "", "input('_x', float)", "input('_y', float)", "input('zmin', float)", "input('zmax', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.extrude_z(shape, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(_x, _y, zmin), (_x, _y, zmax)], color=sb.color.green)", "sb.ui.point(_x, _y, zmin, color=sb.color.green)", "sb.ui.point(_x, _y, zmax, color=sb.color.green)", "", "" ], "uid": 6 }, { "datums": [ { "expr": "base.x0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "base.y0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "shaft.r * 3", "name": "r", "type": "float", "uid": 2 }, { "expr": "-0.4243231142567851", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXqYf3',float('-3.000000'),float('-3.000000'),float('-inf'),float('3.000000'),float('3.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -558.91871027468824, 580.95954924310638 ], "name": "top", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 7 }, { "datums": [ { "expr": "\u0011[__6.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "5", "name": "z0", "type": "float", "uid": 1 }, { "expr": "\u0011[__7.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 2 }, { "expr": "10", "name": "z1", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-Zf10-f5Z/+**Zg-Zf5-r+qXqYf3*-f10Z-r+qXqYf1f5',float('-3.000000'),float('-3.000000'),float('5.000000'),float('3.000000'),float('3.000000'),float('10.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -201.52775930366747, 584.33108388806897 ], "name": "cuppart", "script": [ "# Neil Gershenfeld 2/1/15", "# Matt Keeter 6/13/15", "", "import fab", "from fab.types import Shape, Transform", "title('Loft')", "", "input('a', fab.types.Shape)", "input('z0', float)", "input('b', fab.types.Shape)", "input('z1', float)", "", "", "def loft_xy_z(a, b, zmin, zmax):", " \"\"\" Creates a blended loft between two shapes.", "", " Input shapes should be 2D (in the XY plane).", " The resulting loft will be shape a at zmin and b at zmax.", " \"\"\"", " # ((z-zmin)/(zmax-zmin))*b + ((zmax-z)/(zmax-zmin))*a", " # In the prefix string below, we add caps at zmin and zmax then", " # factor out the division by (zmax - zmin)", " dz = zmax - zmin", " c = zmax", " a_, b_ = a.math, b.math", "\t", " ", " ", " return Shape(('aa-Zf%(zmax)g-f%(zmin)g' +", " 'Z/+**Zg-Zf%(zmin)g%(b_)s' +", " '*-f%(zmax)gZ%(a_)sf%(dz)g') % locals(),", " min(a.bounds.xmin, b.bounds.xmin),", " min(a.bounds.ymin, b.bounds.ymin), zmin,", " max(a.bounds.xmax, b.bounds.xmax),", " max(a.bounds.ymax, b.bounds.ymax), zmax)", "", "", "output('out', loft_xy_z(a, b, z0, z1))", "", "" ], "uid": 8 }, { "datums": [ { "expr": "\u0011[__0.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__4.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('iaa-Zf2-f1Z/+*-Zf1-r+qXqYf1*-f2Z-r+qXqYf1.9f1am__f1-r+qXqYf2.66a-f0Z-Zf1',float('-2.660000'),float('-2.660000'),float('0.000000'),float('2.660000'),float('2.660000'),float('2.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 100.78816006206927, -59.436555136172274 ], "name": "u0", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 9 }, { "datums": [ { "expr": "\u0011[__9.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__6.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('iiaa-Zf2-f1Z/+*-Zf1-r+qXqYf1*-f2Z-r+qXqYf1.9f1am__f1-r+qXqYf2.66a-f0Z-Zf1am__f1-r+qXqYf1a-f2Z-Zf5',float('-2.660000'),float('-2.660000'),float('0.000000'),float('2.660000'),float('2.660000'),float('5.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 162.43045070677201, 118.79241917360939 ], "name": "u1", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 10 }, { "datums": [ { "expr": "\u0011[__10.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__8.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('iiiaa-Zf2-f1Z/+*-Zf1-r+qXqYf1*-f2Z-r+qXqYf1.9f1am__f1-r+qXqYf2.66a-f0Z-Zf1am__f1-r+qXqYf1a-f2Z-Zf5aa-Zf10-f5Z/+**Zg-Zf5-r+qXqYf3*-f10Z-r+qXqYf1f5',float('-3.000000'),float('-3.000000'),float('0.000000'),float('3.000000'),float('3.000000'),float('10.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 172.12779104747483, 303.04188564696273 ], "name": "u2", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 11 }, { "datums": [ { "expr": "\u0011[__11.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('iiiaa-Zf2-f1Z/+*-Zf1-r+qXqYf1*-f2Z-r+qXqYf1.9f1am__f1-r+qXqYf2.66a-f0Z-Zf1am__f1-r+qXqYf1a-f2Z-Zf5aa-Zf10-f5Z/+**Zg-Zf5-r+qXqYf3*-f10Z-r+qXqYf1f5',float('-3.000000'),float('-3.000000'),float('0.000000'),float('3.000000'),float('3.000000'),float('10.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 378.1962732874095, 480.01834686478895 ], "name": "m0", "script": [ "import fab", "", "title('Mesh (.stl)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.stl(shape)", "" ], "uid": 12 } ], "protocol": 6, "type": "sb" }