Hi,
is it possible to import terrain coordinate info (as comma separated values) into Blender 2.5? When imported I need to skin the points with a quad mesh.
Any insights would be much appreciated.
Thanks
James
Hi,
is it possible to import terrain coordinate info (as comma separated values) into Blender 2.5? When imported I need to skin the points with a quad mesh.
Any insights would be much appreciated.
Thanks
James
It’s possible, but you’d need some python scripting for the import.
what’s the format of the csv? does it give columns/rows or is it face definitions?
Hi, thanks for your response.
Here is a random sample of the data:
169700,850950,220
169700,850900,224
169700,850850,226
169700,850800,228
169700,850750,234
169700,850700,239
169700,850650,242
all values are in metres, it’s a 50m grid Eastings, Northings, Altitude. The file I’m looking to use is 30MB. There are no headers or footers in the file as far as I can tell.
I guess the scripting may be reasonably straightforward?
well, pseudocoding it might help get you started:
#read in the lines
#for every 4 vertecies, make a face - this might need some tweaking
#close file
you might want to start with a small segment and make sure it works first, then test a larger segment. I’m guessing it’s going to read like a page:
Line 1(start here->): ============
Line 2: *****************
Line 3: ---------------------
I’m not sure how you would tell if you’re starting a new “line” of faces though - maybe see if the space between current vertex and next vertex are greater than 5 ish?
This is how to make a quad face from vertecies:
http://blenderartists.org/forum/showthread.php?t=197978&highlight=manipulating+geometry&page=2
and this is my stab at reading in the file/ making a face - it almost works(see the console for vertex output):
import bpy
from mathutils import Vector
import sys
file = open("c:\ xt.txt")
vcount = 8
fcount = 6
count = 0
for i in file.readlines():
#print(i)
a = i.split(",")
scale = .00001
x=float(a[0])
y=float(a[1])
z=float(a[2])
newVertex= Vector((x*scale,y*scale,z*scale))
cube = bpy.data.objects['Cube']
cube.data.vertices.add(1)
cube.data.vertices[vcount].co = newVertex
print (vcount,newVertex)
vcount +=1
count+=1
if(count %4 ==0):
print("let's make a face! count is:", count)
cube.data.faces.add(1)
cube.data.faces[fcount].vertices_raw = [(vcount-3),(vcount-2),(vcount-1),vcount]
fcount+=1
cube.data.update(calc_edges=True)
#memory block tnorms corrupt
#
#
#"0 thru 7 are cube data objects"
#cube.data.vertices[8].co = Vector((0,0,3))
#cube.data.vertices[9].co = Vector((1,0,3))
#cube.data.vertices[10].co = Vector((1,1,3))
#cube.data.vertices[11].co = Vector((0,1,3))
#
#cube.data.faces.add(1)
#cube.data.faces[6].vertices_raw = [8,9,10,11]
#cube.data.update(calc_edges=True)
#
I keep getting an error in the console “memory block tnorms corrupt”
which means I’m setting something in memory that i’m not supposed to. My guess is that the vertices_raw might have something to do with it. anyways, your vertices are imported correctly
-amdbcg
Thanks for this information AMDBCG :), I’m looking at this now.
cheers
James
Meshlab http://meshlab.sourceforge.net now imports xyz files. But I don’t know anything about the format so I don’t know how useful this info might be.
Meshlab works fine with Blender.
Open XYZ file, Filters > Remeshing > Surface Reconstruction Ball Pivoting, save as STL or PLY.
Removing doubles in Blender is recommended.
One tip: don’t mess about directly with those vertices and faces attributes in the mesh data. Instead, use the from_pydata method to load the vertices, edges and faces from arrays that you supply in one go. It knows the peculiarities of the required formats to put into those attributes.