3
$\begingroup$

I have a number of relatively straightforward line charts, such as this:

enter image description here

It would be great if I could somehow import the data points into Blender, perhaps to define a curve, to allow me to produce some cool looking data visualisations.

Apologies if I've not been clear in my question, any help is appreciated!

Thanks,

Alex.

$\endgroup$
3
  • 1
    $\begingroup$ what is the data format? excel file? $\endgroup$
    – Tak
    Feb 22, 2017 at 11:55
  • $\begingroup$ It's currently in Excel, but I could export it to any required format, or add it to a Python array. $\endgroup$
    – Alex Cole
    Feb 22, 2017 at 12:02
  • 1
    $\begingroup$ check this answer blender.stackexchange.com/a/71466/2517 $\endgroup$
    – Tak
    Feb 22, 2017 at 12:14

1 Answer 1

2
$\begingroup$

You can use the 'from_pydata(...)' function to create a mesh. This function accepts a list of vertices, a list of edges, and a list of faces.

The vertices should be formatted as a list of X,Y,Z triplets (defining each coordinate in space) while the 'edges' and 'faces' define which of those vertices are linked (by specifying the index in the list of vertices (with 0 being the first in the list, 1 the second, etc.)). Edges can be empty if you are defining just the Faces and similarly Faces can be empty if you are defining just the Edges).

To illustrate, the following example will create a new object (a skewed pyramid) with 4 vertices and 4 faces :

    import bpy

    bpy.ops.object.add(type='MESH', enter_editmode=False, location=(0,0,0))
    o = bpy.context.object
    o.name = 'myobject'
    o.data.from_pydata([(0,0,0),(1,0,0),(0,1,0),(0,0,1)],[],[(0,1,2),(0,1,3),(1,2,3),(0,2,3)])
    o.data.update()

The first argument to from_pydata ("[(0,0,0),(1,0,0),(0,1,0),(0,0,1)]") defines the 4 vertices in space while the last one ("[(0,1,2),(0,1,3),(1,2,3),(0,2,3)]") defines the faces (ie, the first one being between vertex 0, vertex 1 and vertex 2).

For your particular case you should be able to use your raw data to generate a set of vertices and then use the Edges argument to define the Edge between those vertices (ie, 0 to 1, 1 to 2, 2 to 3, etc. along the chain - ie, "[(0,1),(1,2),(2,3),...etc..."). Once created as edges you could then simply add a Skin modifier to convert it into a solid mesh.

See http://blenderscripting.blogspot.co.uk/2011/06/using-frompydata.html and https://wiki.blender.org/index.php/Dev:Py/Scripts/Cookbook/Code_snippets/Three_ways_to_create_objects for some further examples.

$\endgroup$
1
  • $\begingroup$ Apologies for the delay in responding, I was away from my desk. Thanks for this answer, it's perfectly explained and exactly what I needed! $\endgroup$
    – Alex Cole
    Feb 27, 2017 at 12:19

You must log in to answer this question.

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