{ "nodes": [ { "datums": [ { "expr": "\u0011[__1.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0", "name": "_x", "type": "float", "uid": 1 }, { "expr": "0", "name": "_y", "type": "float", "uid": 2 }, { "expr": "4", "name": "i", "type": "int", "uid": 3 }, { "expr": "1", "name": "j", "type": "int", "uid": 4 }, { "expr": "30", "name": "dx", "type": "float", "uid": 5 }, { "expr": "1", "name": "dy", "type": "float", "uid": 6 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf9.5',float('-54.500000'),float('-9.500000'),float('-inf'),float('54.500000'),float('9.500000'),float('inf'))", "name": "array", "type": "_fabtypes.Shape", "uid": 7 } ], "inspector": [ 321.8462833927515, -228.85073208229224 ], "name": "a0", "script": [ "import fab", "", "title('Array (2D)')", "", "input('shape', fab.types.Shape)", "input('_x', float)", "input('_y', float)", "input('i', int)", "input('j', int)", "input('dx', float)", "input('dy', float)", "", "output('array', fab.shapes.iterate3d(shape, i, j, 1, dx, dy, 0))", "", "# UI", "sb.ui.wireframe([", " (_x + dx, _y, 0), (_x, _y, 0), (_x, _y + dy, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + dx, _y - 0.3, 0), (_x + dx, _y + 0.3, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + 0.3, _y + dy, 0), (_x - 0.3, _y + dy, 0)], color=sb.color.teal)", "", "sb.ui.point(_x, _y, 0, color=sb.color.teal)", "sb.ui.point(_x + dx, _y, 0, color=sb.color.teal, drag=(dx, None, None))", "sb.ui.point(_x, _y + dy, 0, color=sb.color.teal, drag=(None, dy, None))", "" ], "uid": 5 }, { "datums": [ { "expr": "-r1.width/2+20", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "9.5", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf-45qYf9.5',float('-54.500000'),float('-9.500000'),float('-inf'),float('-35.500000'),float('9.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -35.63910414545871, -318.96998210185552 ], "name": "c0", "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": "-r1.width/2+20", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "7.5", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf-45qYf7.5',float('-52.500000'),float('-7.500000'),float('-inf'),float('-37.500000'),float('7.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -45.395618792840565, -510.23947507205816 ], "name": "c1", "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": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0", "name": "_x", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 2 }, { "expr": "4", "name": "i", "type": "int", "uid": 3 }, { "expr": "1", "name": "j", "type": "int", "uid": 4 }, { "expr": "30", "name": "dx", "type": "float", "uid": 5 }, { "expr": "1", "name": "dy", "type": "float", "uid": 6 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf7.5',float('-52.500000'),float('-7.500000'),float('-inf'),float('52.500000'),float('7.500000'),float('inf'))", "name": "array", "type": "_fabtypes.Shape", "uid": 7 } ], "inspector": [ 314.55933307629243, -596.69407471347017 ], "name": "a1", "script": [ "import fab", "", "title('Array (2D)')", "", "input('shape', fab.types.Shape)", "input('_x', float)", "input('_y', float)", "input('i', int)", "input('j', int)", "input('dx', float)", "input('dy', float)", "", "output('array', fab.shapes.iterate3d(shape, i, j, 1, dx, dy, 0))", "", "# UI", "sb.ui.wireframe([", " (_x + dx, _y, 0), (_x, _y, 0), (_x, _y + dy, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + dx, _y - 0.3, 0), (_x + dx, _y + 0.3, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + 0.3, _y + dy, 0), (_x - 0.3, _y + dy, 0)], color=sb.color.teal)", "", "sb.ui.point(_x, _y, 0, color=sb.color.teal)", "sb.ui.point(_x + dx, _y, 0, color=sb.color.teal, drag=(dx, None, None))", "sb.ui.point(_x, _y + dy, 0, color=sb.color.teal, drag=(None, dy, None))", "" ], "uid": 3 }, { "datums": [ { "expr": "\u0011[__5.__7]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__3.__7]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf9.5nm-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf7.5',float('-54.500000'),float('-9.500000'),float('-inf'),float('54.500000'),float('9.500000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 690.67143226920359, -431.23561517692269 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 4 }, { "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": "5", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__8.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1iiiiiaa-f-65X-Xf65a-f-10Y-Yf10aa-f-55X-Xf55a-f-20Y-Yf20-r+q-Xf-55q-Yf-10f10-r+q-Xf-55q-Yf10f10-r+q-Xf55q-Yf-10f10-r+q-Xf55q-Yf10f10a-f0Z-Zf5',float('-65.000000'),float('-20.000000'),float('0.000000'),float('65.000000'),float('20.000000'),float('5.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 365.05661584615689, 47.37390521650412 ], "name": "e0", "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": "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": "11", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__4.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1am-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf9.5nm-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf7.5a-f0Z-Zf11',float('-54.500000'),float('-9.500000'),float('0.000000'),float('54.500000'),float('9.500000'),float('11.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 723.93246515624139, -650.21967780906368 ], "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": 7 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "130", "name": "width", "type": "float", "uid": 2 }, { "expr": "40", "name": "height", "type": "float", "uid": 3 }, { "expr": "0.5", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('iiiiiaa-f-65X-Xf65a-f-10Y-Yf10aa-f-55X-Xf55a-f-20Y-Yf20-r+q-Xf-55q-Yf-10f10-r+q-Xf-55q-Yf10f10-r+q-Xf55q-Yf-10f10-r+q-Xf55q-Yf10f10',float('-65.000000'),float('-20.000000'),float('-inf'),float('65.000000'),float('20.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -65.145025882845601, 69.959039231485292 ], "name": "r1", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rounded rectangle (center)')", "", "input('x', float)", "input('y', float)", "input('width', float)", "input('height', float)", "input('r', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "", "# This is the circle's radius in actual units (not a 0-1 fraction)", "r_ = r * min(width, height)/2", "", "output('shape', fab.shapes.rounded_rectangle(xmin, xmax, ymin, ymax, r))", "", "def drag_r(this, x, y, z):", " if abs(this.width) < abs(this.height):", " d = abs(this.width)", " mid = this.y + this.height/2 - d/2", " else:", " d = abs(this.width)", " mid = this.y", " r = 1 - (y - mid) / (d/2)", " this.r = float(min(1, max(0, r)))", "", "def drag_hw(this, x, y, z):", " this.height = abs(2 * (y - this.y))", " this.width = abs(2 * (x - this.x))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.wireframe([(xmax - r_, ymax, 0), (xmax, ymax - r_, 0)])", "sb.ui.point(x, y)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "sb.ui.point(xmax, ymax - r_, drag=drag_r, relative=False)", "", "" ], "uid": 8 }, { "datums": [ { "expr": "\u0011[__6.__5,__7.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('iam__f1iiiiiaa-f-65X-Xf65a-f-10Y-Yf10aa-f-55X-Xf55a-f-20Y-Yf20-r+q-Xf-55q-Yf-10f10-r+q-Xf-55q-Yf10f10-r+q-Xf55q-Yf-10f10-r+q-Xf55q-Yf10f10a-f0Z-Zf5am__f1am-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf9.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf9.5nm-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iiim-Xf0-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf30-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf60-Yf0-Zf0-r+q-Xf-45qYf7.5m-Xf90-Yf0-Zf0-r+q-Xf-45qYf7.5a-f0Z-Zf11',float('-65.000000'),float('-20.000000'),float('0.000000'),float('65.000000'),float('20.000000'),float('11.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 746.01561898097418, 4.2029048956674604 ], "name": "m0", "script": [ "import fab", "", "title('Mesh (.stl)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.stl(shape)", "" ], "uid": 0 } ], "protocol": 6, "type": "sb" }