Skip to content

Instantly share code, notes, and snippets.

@MetroWind
Created November 19, 2014 17:48
Show Gist options
  • Save MetroWind/4ef42d74e0fe322ac7db to your computer and use it in GitHub Desktop.
Save MetroWind/4ef42d74e0fe322ac7db to your computer and use it in GitHub Desktop.
import bpy
from mathutils import Vector
w = 1 # weight
Scale = 0.03
def readCoords(filename):
with open(filename, 'r') as File:
Coords = [[float(x) * Scale for x in line.split()] for line in File]
return list(map(Vector, Coords))
ListOfVectors = [Vector((0,0,0)),Vector((1,0,0)),Vector((2,0,0)),Vector((2,3,0)),
Vector((0,2,1))]
ListOfVectors = readCoords("/Volumes/Stuff/3d/Lorenz/3d-data.txt")
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')
for i in range(len(cList)):
# bpy.context.scene.frame_set(i+1)
if i > 0:
polyline.points.add(1)
x, y, z = cList[i]
polyline.points[i].co = (x, y, z, w)
makePolyLine("NameOfMyCurveObject", "NameOfMyCurve", ListOfVectors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment