{ "nodes": [ { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "-0.1", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "0.2", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "1", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXqYf1a-f-0.1Z-Zf0.2',float('-1.000000'),float('-1.000000'),float('-0.100000'),float('1.000000'),float('1.000000'),float('0.200000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -294, -250 ], "name": "c0", "script": [ "import fab", "import math", "", "title('Cylinder (Z)')", "", "input('x', float)", "input('y', float)", "input('zmin', float)", "input('zmax', float)", "input('r', float)", "", "output('shape', fab.shapes.cylinder(x, y, zmin, zmax, r))", "", "# UI", "sb.ui.wireframe([(x, y, zmin), (x, y, zmax)])", "sb.ui.wireframe([(x, y, zmin), (x+r, y, zmin)])", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmin)", " for i in range(36)], close=True)", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmax)", " for i in range(36)], close=True)", "", "sb.ui.point(x, y, zmin)", "sb.ui.point(x, y, zmax)", "sb.ui.point(x + r, y, zmin, drag=(r, None, None))", "" ], "uid": 0 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "\u0011[__0.__3]", "name": "z", "type": "float", "uid": 2 }, { "expr": "\u0011[__0.__3]", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r++qXqYq-Zf0.2f0.2',float('-0.200000'),float('-0.200000'),float('0.000000'),float('0.200000'),float('0.200000'),float('0.400000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -13.279666804900586, -248.2132778008168 ], "name": "s0", "script": [ "import fab", "import math", "", "title('Sphere (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('r', float)", "", "output('shape', fab.shapes.sphere(x, y, z, r))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, z)", " for i in range(36)], close=True)", "sb.ui.wireframe([(x,y,z-r), (x,y,z+r)])", "", "sb.ui.point(x, y, z)", "sb.ui.point(x, y, z + r, drag=(None, None, r))", "sb.ui.point(x, y, z - r, drag=(None, None, r))", "" ], "uid": 1 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "c0.zmax + 0.5*c1.depth", "name": "z", "type": "float", "uid": 2 }, { "expr": "0.15", "name": "width", "type": "float", "uid": 3 }, { "expr": "0.15", "name": "height", "type": "float", "uid": 4 }, { "expr": "3", "name": "depth", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('am__f1aa-f-0.075X-Xf0.075a-f-0.075Y-Yf0.075a-f0.2Z-Zf3.2',float('-0.075000'),float('-0.075000'),float('0.200000'),float('0.075000'),float('0.075000'),float('3.200000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ -305, -17 ], "name": "c1", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/22/15", "", "import fab", "", "title('Cube (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('width', float)", "input('height', float)", "input('depth', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "zmin, zmax = z - depth/2, z + depth/2", "", "output('shape', fab.shapes.cube(xmin, xmax, ymin, ymax, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(xmin, ymin, zmin), (xmax, ymin, zmin),", " (xmax, ymax, zmin), (xmin, ymax, zmin)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmax), (xmax, ymin, zmax),", " (xmax, ymax, zmax), (xmin, ymax, zmax)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmin), (xmin, ymax, zmin),", " (xmin, ymax, zmax), (xmin, ymin, zmax)], close=True)", "sb.ui.wireframe([(xmax, ymin, zmin), (xmax, ymax, zmin),", " (xmax, ymax, zmax), (xmax, ymin, zmax)], close=True)", "", "def drag_hwd(this, dx,dy,dz):", " this.width += 2*dx", " this.height += 2*dy", " this.depth += 2*dz", "", "sb.ui.point(x, y, z)", "sb.ui.point(x + width/2.0, y + height/2.0, z + depth/2.0,", " drag=drag_hwd)", "", "" ], "uid": 2 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "\u0011[__0.__3]", "name": "z", "type": "float", "uid": 2 }, { "expr": "-30", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__2.__6]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0.2m_+*f0.866025Y*f-0.5Z+*f0.5Y*f0.866025Zm-Xf0-Yf-0-Zf-0.2am__f1aa-f-0.075X-Xf0.075a-f-0.075Y-Yf0.075a-f0.2Z-Zf3.2',float('-0.075000'),float('-0.064952'),float('0.162500'),float('0.075000'),float('1.564952'),float('2.835575'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 0, -19 ], "name": "r0", "script": [ "import fab", "import math", "", "title('Rotate (X)')", "", "input('_x', float)", "input('y', float)", "input('z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_x(shape, a, y, z))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(_x, y + math.cos(rad), z + math.sin(rad)),", " (_x, y, z),", " (_x, y + 1, z)], color=sb.color.teal)", "", "# Draw a semi-circular arc showing the rotation", "if int(a) % 360 != 0:", " sb.ui.wireframe([", " (_x, y + math.cos(math.radians(a_)) * 0.3,", " z + math.sin(math.radians(a_)) * 0.3)", " for a_ in range(int(a) % 360)], color=sb.color.teal)", "", "sb.ui.point(_x, y, z, color=sb.color.teal)", "", "def drag_pt(this, x, y, z):", " this.a = math.degrees(math.atan2(z - this.z, y - this.y))", "sb.ui.point(_x, y + math.cos(rad), z + math.sin(rad),", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 3 }, { "datums": [ { "expr": "0.0", "name": "xmin", "type": "float", "uid": 0 }, { "expr": "\u0011[__2.__3]", "name": "xmax", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 2 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 3 }, { "expr": "\u0011[__0.__3]", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('a-r+q-Yf0q-Zf0f0.2a-f0X-Xf0.15',float('0.000000'),float('-0.200000'),float('-0.200000'),float('0.150000'),float('0.200000'),float('0.200000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -304, 248 ], "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": 4 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "1.4932957887649536", "name": "y", "type": "float", "uid": 1 }, { "expr": "2.7772510051727295", "name": "z", "type": "float", "uid": 2 }, { "expr": "\u0011[__4.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf-0.075-Yf1.4933-Zf2.77725a-r+q-Yf0q-Zf0f0.2a-f0X-Xf0.15',float('-0.075000'),float('1.293300'),float('2.577250'),float('0.075000'),float('1.693300'),float('2.977250'))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -12.968498727732594, 258.46457288259131 ], "name": "r1", "script": [ "import fab", "", "title('Recenter')", "", "input('x', float)", "input('y', float)", "input('z', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.recenter(shape, x, y, z))", "", "# UI", "sb.ui.wireframe([(x, y - 0.3, z),", " (x, y + 0.3, z)], color=sb.color.teal)", "sb.ui.wireframe([(x - 0.3, y, z),", " (x + 0.3, y, z)], color=sb.color.teal)", "sb.ui.wireframe([(x, y, z - 0.3),", " (x, y, z + 0.3)], color=sb.color.teal)", "", "sb.ui.point(x, y, z, color=sb.color.teal)", "" ], "uid": 5 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "1.4930219650268555", "name": "y", "type": "float", "uid": 1 }, { "expr": "3.7721426486968994", "name": "z", "type": "float", "uid": 2 }, { "expr": "0.15", "name": "width", "type": "float", "uid": 3 }, { "expr": "0.15", "name": "height", "type": "float", "uid": 4 }, { "expr": "2", "name": "depth", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('am__f1aa-f-0.075X-Xf0.075a-f1.41802Y-Yf1.56802a-f2.77214Z-Zf4.77214',float('-0.075000'),float('1.418022'),float('2.772143'),float('0.075000'),float('1.568022'),float('4.772142'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ -297.86614322064781, 478.8112758998073 ], "name": "c3", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/22/15", "", "import fab", "", "title('Cube (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('width', float)", "input('height', float)", "input('depth', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "zmin, zmax = z - depth/2, z + depth/2", "", "output('shape', fab.shapes.cube(xmin, xmax, ymin, ymax, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(xmin, ymin, zmin), (xmax, ymin, zmin),", " (xmax, ymax, zmin), (xmin, ymax, zmin)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmax), (xmax, ymin, zmax),", " (xmax, ymax, zmax), (xmin, ymax, zmax)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmin), (xmin, ymax, zmin),", " (xmin, ymax, zmax), (xmin, ymin, zmax)], close=True)", "sb.ui.wireframe([(xmax, ymin, zmin), (xmax, ymax, zmin),", " (xmax, ymax, zmax), (xmax, ymin, zmax)], close=True)", "", "def drag_hwd(this, dx,dy,dz):", " this.width += 2*dx", " this.height += 2*dy", " this.depth += 2*dz", "", "sb.ui.point(x, y, z)", "sb.ui.point(x + width/2.0, y + height/2.0, z + depth/2.0,", " drag=drag_hwd)", "", "" ], "uid": 6 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "\u0011[__5.__1]", "name": "y", "type": "float", "uid": 1 }, { "expr": "\u0011[__5.__2]", "name": "z", "type": "float", "uid": 2 }, { "expr": "40", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__6.__6]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf1.4933-Zf2.77725m_+*f0.766044Y*f0.642788Z+*f-0.642788Y*f0.766044Zm-Xf0-Yf-1.4933-Zf-2.77725am__f1aa-f-0.075X-Xf0.075a-f1.41802Y-Yf1.56802a-f2.77214Z-Zf4.77214',float('-0.075000'),float('0.153341'),float('2.724950'),float('0.075000'),float('1.553823'),float('4.353456'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -4.2992148309717457, 480.07898945851167 ], "name": "r2", "script": [ "import fab", "import math", "", "title('Rotate (X)')", "", "input('_x', float)", "input('y', float)", "input('z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_x(shape, a, y, z))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(_x, y + math.cos(rad), z + math.sin(rad)),", " (_x, y, z),", " (_x, y + 1, z)], color=sb.color.teal)", "", "# Draw a semi-circular arc showing the rotation", "if int(a) % 360 != 0:", " sb.ui.wireframe([", " (_x, y + math.cos(math.radians(a_)) * 0.3,", " z + math.sin(math.radians(a_)) * 0.3)", " for a_ in range(int(a) % 360)], color=sb.color.teal)", "", "sb.ui.point(_x, y, z, color=sb.color.teal)", "", "def drag_pt(this, x, y, z):", " this.a = math.degrees(math.atan2(z - this.z, y - this.y))", "sb.ui.point(_x, y + math.cos(rad), z + math.sin(rad),", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 7 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.21", "name": "y", "type": "float", "uid": 1 }, { "expr": "c4.zmax-0.2", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "4.51", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "1", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXq-Yf0.21f1a-f4.31Z-Zf4.51',float('-1.000000'),float('-0.790000'),float('4.310000'),float('1.000000'),float('1.210000'),float('4.510000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 318.47760308084577, -109.50884605945623 ], "name": "c4", "script": [ "import fab", "import math", "", "title('Cylinder (Z)')", "", "input('x', float)", "input('y', float)", "input('zmin', float)", "input('zmax', float)", "input('r', float)", "", "output('shape', fab.shapes.cylinder(x, y, zmin, zmax, r))", "", "# UI", "sb.ui.wireframe([(x, y, zmin), (x, y, zmax)])", "sb.ui.wireframe([(x, y, zmin), (x+r, y, zmin)])", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmin)", " for i in range(36)], close=True)", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmax)", " for i in range(36)], close=True)", "", "sb.ui.point(x, y, zmin)", "sb.ui.point(x, y, zmax)", "sb.ui.point(x + r, y, zmin, drag=(r, None, None))", "" ], "uid": 8 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "\u0011[__8.__1]", "name": "y", "type": "float", "uid": 1 }, { "expr": "\u0011[__8.__2]", "name": "z", "type": "float", "uid": 2 }, { "expr": "\u0011[__0.__3]", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r++qXq-Yf0.21q-Zf4.31f0.2',float('-0.200000'),float('0.010000'),float('4.110000'),float('0.200000'),float('0.410000'),float('4.510000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 608.36497862017154, -102.5022526983405 ], "name": "s1", "script": [ "import fab", "import math", "", "title('Sphere (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('r', float)", "", "output('shape', fab.shapes.sphere(x, y, z, r))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, z)", " for i in range(36)], close=True)", "sb.ui.wireframe([(x,y,z-r), (x,y,z+r)])", "", "sb.ui.point(x, y, z)", "sb.ui.point(x, y, z + r, drag=(None, None, r))", "sb.ui.point(x, y, z - r, drag=(None, None, r))", "" ], "uid": 9 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.21", "name": "y", "type": "float", "uid": 1 }, { "expr": "c5.zmax-0.2", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "4.61", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "0.95", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXq-Yf0.21f0.95a-f4.41Z-Zf4.61',float('-0.950000'),float('-0.740000'),float('4.410000'),float('0.950000'),float('1.160000'),float('4.610000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 334.44428496680666, 331.3331950344251 ], "name": "c5", "script": [ "import fab", "import math", "", "title('Cylinder (Z)')", "", "input('x', float)", "input('y', float)", "input('zmin', float)", "input('zmax', float)", "input('r', float)", "", "output('shape', fab.shapes.cylinder(x, y, zmin, zmax, r))", "", "# UI", "sb.ui.wireframe([(x, y, zmin), (x, y, zmax)])", "sb.ui.wireframe([(x, y, zmin), (x+r, y, zmin)])", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmin)", " for i in range(36)], close=True)", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmax)", " for i in range(36)], close=True)", "", "sb.ui.point(x, y, zmin)", "sb.ui.point(x, y, zmax)", "sb.ui.point(x + r, y, zmin, drag=(r, None, None))", "" ], "uid": 10 }, { "datums": [ { "expr": "\u0011[__8.__5,__9.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__10.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aiam__f1-r+qXq-Yf0.21f1a-f4.31Z-Zf4.51-r++qXq-Yf0.21q-Zf4.31f0.2nam__f1-r+qXq-Yf0.21f0.95a-f4.41Z-Zf4.61',float('-1.000000'),float('-0.790000'),float('4.110000'),float('1.000000'),float('1.210000'),float('4.510000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 631.06733428209304, 343.75915149745128 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 11 }, { "datums": [ { "expr": "\u0011[__11.__2,__0.__5,__1.__4,__3.__5,__5.__4,__7.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('iiiiiaiam__f1-r+qXq-Yf0.21f1a-f4.31Z-Zf4.51-r++qXq-Yf0.21q-Zf4.31f0.2nam__f1-r+qXq-Yf0.21f0.95a-f4.41Z-Zf4.61am__f1-r+qXqYf1a-f-0.1Z-Zf0.2-r++qXqYq-Zf0.2f0.2m-Xf0-Yf0-Zf0.2m_+*f0.866025Y*f-0.5Z+*f0.5Y*f0.866025Zm-Xf0-Yf-0-Zf-0.2am__f1aa-f-0.075X-Xf0.075a-f-0.075Y-Yf0.075a-f0.2Z-Zf3.2m-Xf-0.075-Yf1.4933-Zf2.77725a-r+q-Yf0q-Zf0f0.2a-f0X-Xf0.15m-Xf0-Yf1.4933-Zf2.77725m_+*f0.766044Y*f0.642788Z+*f-0.642788Y*f0.766044Zm-Xf0-Yf-1.4933-Zf-2.77725am__f1aa-f-0.075X-Xf0.075a-f1.41802Y-Yf1.56802a-f2.77214Z-Zf4.77214',float('-1.000000'),float('-1.000000'),float('-0.100000'),float('1.000000'),float('1.693300'),float('4.510000'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 332.83149093347919, 599.41982105010084 ], "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" }