Skip to content

Instantly share code, notes, and snippets.

@baronwatts
Created October 22, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baronwatts/345a1edcac3db862ee78de738c417357 to your computer and use it in GitHub Desktop.
Save baronwatts/345a1edcac3db862ee78de738c417357 to your computer and use it in GitHub Desktop.
import bpy
from mathutils import Vector
# weight
w = 1.0000
#replace with [(x,y,z), (x,y,z), (x,y,z)]
listOfVectors = [(-0.1277, 4.0407, -1.0315),(-0.0555, 4.0030, -1.0374),(0.0176, 3.9602, -1.0428),(0.0918, 3.9126, -1.0476),(0.1669, 3.8607, -1.0519),(0.2427, 3.8048, -1.0557),(0.3193, 3.7456, -1.0589),(0.3965, 3.6832, -1.0618),(0.4742, 3.6183, -1.0642),(0.5524, 3.5512, -1.0662),(0.6310, 3.4823, -1.0679),(0.7098, 3.4120, -1.0692),(0.7888, 3.3409, -1.0702),(0.8679, 3.2693, -1.0709),(0.9470, 3.1975, -1.0714),(1.0259, 3.1258, -1.0717),(1.1044, 3.0542, -1.0716),(1.1821, 2.9827, -1.0714),(1.2589, 2.9115, -1.0708),(1.3344, 2.8404, -1.0699),(1.4085, 2.7696, -1.0688),(1.4808, 2.6992, -1.0674),(1.5512, 2.6291, -1.0656),(1.6193, 2.5595, -1.0636),(1.6850, 2.4904, -1.0612),(1.7479, 2.4217, -1.0585),(1.8079, 2.3537, -1.0554),(1.8647, 2.2862, -1.0520),(1.9184, 2.2194, -1.0483),(1.9691, 2.1531, -1.0443),(2.0173, 2.0873, -1.0401),(2.0631, 2.0220, -1.0357),(2.1067, 1.9571, -1.0312),(2.1485, 1.8926, -1.0266),(2.1887, 1.8283, -1.0220),(2.2275, 1.7643, -1.0173),(2.2651, 1.7006, -1.0128),(2.3020, 1.6370, -1.0083),(2.3382, 1.5735, -1.0039),(2.3740, 1.5101, -0.9998),(2.4097, 1.4467, -0.9958),(2.4453, 1.3832, -0.9922),(2.4807, 1.3195, -0.9887),(2.5156, 1.2553, -0.9854),(2.5499, 1.1904, -0.9823),(2.5834, 1.1248, -0.9794),(2.6160, 1.0581, -0.9766),(2.6474, 0.9904, -0.9739),(2.6776, 0.9212, -0.9713),(2.7063, 0.8506, -0.9687),(2.7334, 0.7783, -0.9662),(2.7587, 0.7041, -0.9636),(2.7820, 0.6278, -0.9611),(2.8032, 0.5493, -0.9586),(2.8222, 0.4686, -0.9559),(2.8392, 0.3858, -0.9533),(2.8543, 0.3011, -0.9507),(2.8678, 0.2147, -0.9480),(2.8798, 0.1267, -0.9454),(2.8905, 0.0374, -0.9429),(2.9000, -0.0532, -0.9403),(2.9086, -0.1447, -0.9379),(2.9163, -0.2371, -0.9355),(2.9234, -0.3302, -0.9332),(2.9300, -0.4238, -0.9311),(2.9363, -0.5176, -0.9291),(2.9425, -0.6116, -0.9272),(2.9487, -0.7056, -0.9255),(2.9548, -0.7995, -0.9239),(2.9609, -0.8932, -0.9225),(2.9667, -0.9867, -0.9212),(2.9724, -1.0798, -0.9201),(2.9779, -1.1725, -0.9191),(2.9831, -1.2647, -0.9181),(2.9880, -1.3563, -0.9173),(2.9926, -1.4473, -0.9166),(2.9967, -1.5376, -0.9161),(3.0004, -1.6271, -0.9155),(3.0036, -1.7156, -0.9151),(3.0063, -1.8033, -0.9148),(3.0083, -1.8898, -0.9144),(3.0089, -1.9749, -0.9139),(3.0075, -2.0583, -0.9128),(3.0034, -2.1396, -0.9109),(2.9958, -2.2186, -0.9080),(2.9841, -2.2948, -0.9037),(2.9676, -2.3680, -0.8978),(2.9455, -2.4378, -0.8900),(2.9172, -2.5040, -0.8800),(2.8819, -2.5661, -0.8676),(2.8390, -2.6238, -0.8524),(2.7877, -2.6769, -0.8342),(2.7274, -2.7249, -0.8128),(2.6576, -2.7676, -0.7879),(2.5790, -2.8050, -0.7597),(2.4926, -2.8371, -0.7286),(2.3996, -2.8639, -0.6949),(2.3009, -2.8854, -0.6591),(2.1976, -2.9016, -0.6213),(2.0907, -2.9126, -0.5820),(1.9813, -2.9184, -0.5414),(1.8704, -2.9190, -0.5001),(1.7591, -2.9144, -0.4582),(1.6485, -2.9047, -0.4161),(1.5395, -2.8898, -0.3742),(1.4332, -2.8699, -0.3327),(1.3305, -2.8448, -0.2921),(1.2320, -2.8144, -0.2525),(1.1375, -2.7786, -0.2140),(1.0473, -2.7370, -0.1767),(0.9614, -2.6894, -0.1406),(0.8800, -2.6357, -0.1059),(0.8030, -2.5755, -0.0727),(0.7307, -2.5087, -0.0411),(0.6631, -2.4349, -0.0111),(0.6003, -2.3541, 0.0171),(0.5425, -2.2658, 0.0434),(0.4896, -2.1700, 0.0678),(0.4418, -2.0664, 0.0902),(0.3992, -1.9548, 0.1104),(0.3612, -1.8356, 0.1285),(0.3270, -1.7099, 0.1447),(0.2957, -1.5784, 0.1591),(0.2663, -1.4422, 0.1720),(0.2380, -1.3021, 0.1833),(0.2099, -1.1591, 0.1935),(0.1811, -1.0141, 0.2025),(0.1507, -0.8680, 0.2105),(0.1179, -0.7218, 0.2177),(0.0816, -0.5763, 0.2243),(0.0411, -0.4325, 0.2304),(-0.0046, -0.2912, 0.2361),(-0.0563, -0.1535, 0.2417),(-0.1141, -0.0196, 0.2472),(-0.1772, 0.1107, 0.2526),(-0.2450, 0.2377, 0.2578),(-0.3167, 0.3616, 0.2628),(-0.3915, 0.4827, 0.2677),(-0.4688, 0.6012, 0.2723),(-0.5476, 0.7174, 0.2766),(-0.6274, 0.8316, 0.2807),(-0.7073, 0.9440, 0.2845),(-0.7866, 1.0549, 0.2880),(-0.8646, 1.1645, 0.2911),(-0.9405, 1.2731, 0.2938),(-1.0136, 1.3810, 0.2962),(-1.0836, 1.4880, 0.2981),(-1.1513, 1.5935, 0.2998),(-1.2174, 1.6970, 0.3014),(-1.2824, 1.7977, 0.3028),(-1.3472, 1.8950, 0.3044),(-1.4124, 1.9883, 0.3061),(-1.4787, 2.0769, 0.3080),(-1.5468, 2.1603, 0.3104),(-1.6175, 2.2376, 0.3132),(-1.6913, 2.3083, 0.3166),(-1.7691, 2.3718, 0.3207),(-1.8515, 2.4274, 0.3256),(-1.9393, 2.4745, 0.3315),(-2.0324, 2.5125, 0.3383),(-2.1298, 2.5418, 0.3461),(-2.2302, 2.5625, 0.3547),(-2.3322, 2.5746, 0.3642),(-2.4345, 2.5786, 0.3744),(-2.5357, 2.5745, 0.3853),(-2.6345, 2.5625, 0.3969),(-2.7297, 2.5428, 0.4091),(-2.8197, 2.5156, 0.4218),(-2.9034, 2.4812, 0.4350),(-2.9794, 2.4397, 0.4487),(-3.0463, 2.3912, 0.4627),(-3.1029, 2.3360, 0.4770),(-3.1481, 2.2745, 0.4916),(-3.1819, 2.2074, 0.5064),(-3.2046, 2.1358, 0.5213),(-3.2164, 2.0606, 0.5363),(-3.2176, 1.9829, 0.5512),(-3.2084, 1.9035, 0.5660),(-3.1891, 1.8235, 0.5808),(-3.1600, 1.7438, 0.5952),(-3.1213, 1.6653, 0.6094),(-3.0732, 1.5892, 0.6233),(-3.0161, 1.5163, 0.6367),(-2.9501, 1.4476, 0.6496),(-2.8755, 1.3842, 0.6619),(-2.7928, 1.3266, 0.6737),(-2.7028, 1.2748, 0.6848),(-2.6070, 1.2281, 0.6953),(-2.5065, 1.1859, 0.7053),(-2.4027, 1.1475, 0.7147),(-2.2968, 1.1123, 0.7235),(-2.1900, 1.0797, 0.7319),(-2.0837, 1.0491, 0.7398),(-1.9790, 1.0199, 0.7473),(-1.8774, 0.9915, 0.7543),(-1.7799, 0.9632, 0.7609),(-1.6880, 0.9344, 0.7672),(-1.6029, 0.9046, 0.7730),(-1.5256, 0.8730, 0.7786),(-1.4562, 0.8391, 0.7839),(-1.3942, 0.8024, 0.7889),(-1.3389, 0.7624, 0.7938),(-1.2898, 0.7184, 0.7985),(-1.2462, 0.6700, 0.8032),(-1.2076, 0.6167, 0.8080),(-1.1734, 0.5577, 0.8128),(-1.1431, 0.4928, 0.8177),(-1.1159, 0.4212, 0.8229),(-1.0914, 0.3424, 0.8282),(-1.0690, 0.2560, 0.8339),(-1.0480, 0.1613, 0.8400),(-1.0280, 0.0579, 0.8465),(-1.0088, -0.0538, 0.8534),(-0.9909, -0.1725, 0.8608),(-0.9745, -0.2972, 0.8685),(-0.9600, -0.4265, 0.8767),(-0.9478, -0.5594, 0.8852),(-0.9382, -0.6946, 0.8940),(-0.9315, -0.8309, 0.9032),(-0.9282, -0.9672, 0.9126),(-0.9284, -1.1022, 0.9224),(-0.9327, -1.2347, 0.9323),(-0.9413, -1.3637, 0.9426),(-0.9546, -1.4877, 0.9530),(-0.9730, -1.6058, 0.9636),(-0.9964, -1.7173, 0.9745),(-1.0248, -1.8221, 0.9854),(-1.0579, -1.9204, 0.9965),(-1.0956, -2.0122, 1.0076),(-1.1376, -2.0975, 1.0189),(-1.1838, -2.1764, 1.0301),(-1.2339, -2.2490, 1.0414),(-1.2878, -2.3153, 1.0526),(-1.3452, -2.3753, 1.0638),(-1.4059, -2.4291, 1.0749),(-1.4699, -2.4768, 1.0859),(-1.5367, -2.5184, 1.0968),(-1.6064, -2.5539, 1.1076),(-1.6785, -2.5836, 1.1181),(-1.7527, -2.6078, 1.1284),(-1.8287, -2.6271, 1.1383),(-1.9059, -2.6417, 1.1479),(-1.9840, -2.6522, 1.1570),(-2.0627, -2.6590, 1.1657),(-2.1414, -2.6626, 1.1738),(-2.2199, -2.6633, 1.1813),(-2.2976, -2.6616, 1.1881),(-2.3743, -2.6579, 1.1942),(-2.4495, -2.6527, 1.1995),(-2.5227, -2.6464, 1.2040),(-2.5937, -2.6395, 1.2075),(-2.6622, -2.6322, 1.2101),(-2.7282, -2.6246, 1.2117),(-2.7921, -2.6168, 1.2123),(-2.8540, -2.6088, 1.2118),(-2.9140, -2.6006, 1.2103),(-2.9725, -2.5922, 1.2076),(-3.0295, -2.5837, 1.2038),(-3.0854, -2.5750, 1.1989),(-3.1402, -2.5662, 1.1927),(-3.1943, -2.5573, 1.1854),(-3.2478, -2.5483, 1.1768),(-3.3008, -2.5394, 1.1669),(-3.3537, -2.5303, 1.1557)]
def MakePolyLine(objname, curvename, cList):
curvedata = bpy.data.curves.new(name=curvename, type='CURVE')
curvedata.dimensions = '3D'
objectdata = bpy.data.objects.new(objname, curvedata)
objectdata.location = (0,0,0) #object origin
bpy.context.scene.objects.link(objectdata)
polyline = curvedata.splines.new('NURBS')
polyline.points.add(len(cList)-1)
for num in range(len(cList)):
polyline.points[num].co = (cList[num])+(w,)
polyline.order_u = len(polyline.points)-1
polyline.use_endpoint_u = True
MakePolyLine("NameOfMyCurveObject", "NameOfMyCurve", listOfVectors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment