{ "nodes": [ { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "10", "name": "width", "type": "float", "uid": 2 }, { "expr": "2", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f-5X-Xf5a-f-1Y-Yf1',float('-5.000000'),float('-1.000000'),float('-inf'),float('5.000000'),float('1.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 38.253024826356551, 597.4758163354735 ], "name": "r0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rectangle (center)')", "", "input('x0', float)", "input('y0', float)", "input('width', float)", "input('height', float)", "", "xmin, xmax = x0 - width/2, x0 + width/2", "ymin, ymax = y0 - height/2, y0 + height/2", "", "output('shape', fab.shapes.rectangle(xmin, xmax, ymin, ymax))", "", "def drag_hw(this, x, y, z):", " this.width = abs(2 * (x - this.x0))", " this.height = abs(2 * (y - this.y0))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.point(x0, y0)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "" ], "uid": 0 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-1", "name": "y0", "type": "float", "uid": 1 }, { "expr": ".36", "name": "r", "type": "float", "uid": 2 }, { "expr": "0", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+qXq-Yf-1f0.36',float('-0.360000'),float('-1.360000'),float('-inf'),float('0.360000'),float('-0.640000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 34.609879604798778, 384.35182087434418 ], "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": "\u0011[__0.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__1.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aaa-f-5X-Xf5a-f-1Y-Yf1n-r+qXq-Yf-1f0.36',float('-5.000000'),float('-1.000000'),float('-inf'),float('5.000000'),float('1.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 29.145161772462131, 213.1239954611292 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 2 }, { "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": "10", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "\u0011[__2.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1aaa-f-5X-Xf5a-f-1Y-Yf1n-r+qXq-Yf-1f0.36a-f0Z-Zf10',float('-5.000000'),float('-1.000000'),float('0.000000'),float('5.000000'),float('1.000000'),float('10.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 10.929435664673292, -67.398186598818711 ], "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": 3 }, { "datums": [ { "expr": "-5", "name": "xmin", "type": "float", "uid": 0 }, { "expr": "5", "name": "xmax", "type": "float", "uid": 1 }, { "expr": "-1", "name": "y", "type": "float", "uid": 2 }, { "expr": "5", "name": "z", "type": "float", "uid": 3 }, { "expr": ".36", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('a-r+q-Yf-1q-Zf5f0.36a-f-5X-Xf5',float('-5.000000'),float('-1.360000'),float('4.640000'),float('5.000000'),float('-0.640000'),float('5.360000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 411.85065744307514, -73.401498417926121 ], "name": "c2", "script": [ "import fab", "import math", "", "title('Cylinder (X)')", "", "input('xmin', float)", "input('xmax', float)", "input('y', float)", "input('z', float)", "input('r', float)", "", "output('shape', fab.shapes.cylinder_x(xmin, xmax, y, z, r))", "", "# UI", "sb.ui.wireframe([(xmin, y, z), (xmax, y, z)])", "sb.ui.wireframe([(xmin, y, z), (xmin, y, z + r)])", "", "sb.ui.wireframe([", " (xmin, math.cos(i/36. * 2*math.pi) * r + y,", " math.sin(i/36. * 2*math.pi) * r + z)", " for i in range(36)], close=True)", "", "sb.ui.wireframe([", " (xmax, math.cos(i/36. * 2*math.pi) * r + y,", " math.sin(i/36. * 2*math.pi) * r + z)", " for i in range(36)], close=True)", "", "sb.ui.point(xmin, y, z)", "sb.ui.point(xmax, y, z)", "sb.ui.point(xmin, y, z + r, drag=(None, None, r))", "" ], "uid": 5 }, { "datums": [ { "expr": "\u0011[__3.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__5.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aam__f1aaa-f-5X-Xf5a-f-1Y-Yf1n-r+qXq-Yf-1f0.36a-f0Z-Zf10na-r+q-Yf-1q-Zf5f0.36a-f-5X-Xf5',float('-5.000000'),float('-1.000000'),float('0.000000'),float('5.000000'),float('1.000000'),float('10.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 452.3923177736616, 229.4275325852141 ], "name": "d1", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 6 }, { "datums": [ { "expr": "\u0011[__6.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('aam__f1aaa-f-5X-Xf5a-f-1Y-Yf1n-r+qXq-Yf-1f0.36a-f0Z-Zf10na-r+q-Yf-1q-Zf5f0.36a-f-5X-Xf5',float('-5.000000'),float('-1.000000'),float('0.000000'),float('5.000000'),float('1.000000'),float('10.000000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 477.25202402406796, 466.32258835939462 ], "name": "m0", "script": [ "import fab", "", "title('Mesh (.stl)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.stl(shape)", "" ], "uid": 4 } ], "protocol": 6, "type": "sb" }