I have some text files that contain the (x, y, z) values of points that make up a curve. How can I import this curve into blender, add some thickness, and, if possible, color the line by a fourth variable (like time)?

As an example, here is a python script that prints x, y, z and t values for a spiral:

import numpy as np

t = np.linspace(0,10,100)

x = np.sin(t)
y = np.cos(t)
z = t

for vec in zip(x, y, z, t):
    print '%.2f %.2f %.2f %.2f'%(vec[0],vec[1],vec[2],vec[3])

And the output looks like my data files:

0.00 1.00 0.00 0.00
0.10 0.99 0.10 0.10
0.20 0.98 0.20 0.20
0.30 0.95 0.30 0.30
0.39 0.92 0.40 0.40
0.48 0.88 0.51 0.51
0.57 0.82 0.61 0.61
0.65 0.76 0.71 0.71
0.72 0.69 0.81 0.81
0.79 0.61 0.91 0.91
0.85 0.53 1.01 1.01
0.90 0.44 1.11 1.11
0.94 0.35 1.21 1.21
0.97 0.25 1.31 1.31
0.99 0.16 1.41 1.41

How can I import this data into Blender? (Note: I have used the 3D surface plugin to draw lines and surfaces in Blender. This is not what I am asking here. In this case, I don't want to plot an equation, but experimental data from text files.)


3 Answers 3


One easy solution, though kind of "hacky", would be to append "v " (a lowercase v and a space) to the beginning of each line, and then importing it has a Wavefront .obj format.

So just do: print "v " + '%.2f %.2f %.2f %.2f'%(vec[0],vec[1],vec[2],vec[3])

In this example three vertices are defined, then they are automatically assigned an index from top to bottom;

v 0.00 1.00 0.00 0.00 #This is the index 1
v 0.10 0.99 0.10 0.10 #This is the index 2
v 0.20 0.98 0.20 0.20 #This is the index 3

Then, to define a "face" (a connection of 2 or more vertices) use:

f 1 2 3

Using this will define a face between the vertices of index 1, 2 and 3.

If, however, you want to only connect vertices with edges, you can use:

l 1 2

To define an edge between vertices of index 1 and 2.

If you want a brief explanation, there's a Wikipedia page. For the complete specification, refer to this page.

  • $\begingroup$ This works well to import the individual points. But how do I connect the vertices? $\endgroup$ Oct 3, 2014 at 0:21
  • $\begingroup$ @DanHickstein There... $\endgroup$ Oct 3, 2014 at 18:23
  • $\begingroup$ This almost works. I can use f 1/2 2/3 3/4 4/5 ... to connect the vertices. However, the first and the last vertex always get connected in Blender, so the object does not look quite right. $\endgroup$ Oct 7, 2014 at 16:45
  • $\begingroup$ @DanHickstein Check the answer again; I've specified how to add simple edges. $\endgroup$ Oct 15, 2014 at 21:12

New Offer Python Script Screen Capture ...

Please inspect and test and improve and critique if you choose to use. enter image description here

The red short curve segments are generated by the python. The color is graduated and repeated. Substitute your data. Your browser may allow you to [see image] at full size.

Older Writing

Perhaps you can change your points to a line equation y = mx + b and use the same plugin. Perhaps the plugin has this feature already.

This is a high level description of some steps to be written in Python:

  1. Open the file, read the values into some number sequence variable. Print them to the console for inspection.

  2. Create or copy a Bezier curve. The curve points are assigned the points from [step 1]. Set the resolution value to 1 and the extrude value to greater than zero.

  3. Copy a material and set diffuse value as a ratio of bias + (time/maxtime).

Certainly a script similar to your needs exists and needs to be found. Plotting scripts seems like a generally useful category.

Consider inspecting some similar scripts supplied with Blender or elsewhere.

  • $\begingroup$ thanks for your suggestions. My questions was a little unclear and I edited it to reflect that I would indeed prefer a curve defined by these points. I think that your recommended techniques should work, but I don't know enough about blender to know how to make a bezier curve in the terminal. So, I really need a low-level example of how to do this. Thanks. $\endgroup$ Oct 2, 2014 at 14:24
  • $\begingroup$ @DanHickstein . Does low level mean (01) Blender with Keyboard & Mouse (02) Blender with Python Script? $\endgroup$ Oct 2, 2014 at 14:46
  • $\begingroup$ I think that it would take a python script. $\endgroup$ Oct 2, 2014 at 20:30

A good approach to this is listed here: Poly / Bezier curve from a list of coordinates

I just use


to load my datafile and then use the script listed at the above link to add the curve.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .