3
$\begingroup$

I have a .3ds file which I import into Blender. vertices

Now what I'm trying to do is to export the coordinates of vertices into a .ply file. When I export these vertices into a .ply file they are not correct. It seems that it only exports the coordinates of the single face which you can see in the picture. How can I export those vertices correctly?

EDIT The .csv structure:

1;2;3\n

4;5;6\n

... Each column is separated by a semicolon and each row by a new line.

$\endgroup$
  • $\begingroup$ Appears the ply exporter does not allow exporting solitary verts (that are not parts of faces). Why not use a different export format? $\endgroup$ – TLousky Apr 30 '16 at 15:31
  • $\begingroup$ I have a script which will convert the ply into .csv. The .csv then goes to Matlab for further manipulation... Basically what I need are the data containing the coordinates. I'm okay with any other file type until I will be able to read it and convert it into a .csv $\endgroup$ – Peter H. Apr 30 '16 at 16:16
  • $\begingroup$ You can generate your csv directly from blender using the Python API. If you add the CSV structure to your question we can help you write such a script. $\endgroup$ – TLousky Apr 30 '16 at 16:39
  • $\begingroup$ @TLousky I just added the structure of CSV into my question $\endgroup$ – Peter H. Apr 30 '16 at 16:46
  • $\begingroup$ Wrote an answer, give it a go and let us know if it works for you. $\endgroup$ – TLousky Apr 30 '16 at 16:58
5
$\begingroup$

You can generate your CSV directly from blender using the script below. It will generate a semi-colon separated list of coordinates for each vertex in the active mesh.

It requires you to select and set the mesh you want to export as the active object.

import bpy

outputFile = 'C:/someFolder/mesh.csv'

verts = [ bpy.context.object.matrix_world * v.co for v in bpy.context.object.data.vertices ]

csvLines = [ ";".join([ str(v) for v in co ]) + "\n" for co in verts ]

f = open( outputFile, 'w' )
f.writelines( csvLines )
f.close()

Here's how the CSV data looks like when exporting the coordiantes of a default icosphere (2 subdivisions, 42 verts):

enter image description here

0.0;0.0;-1.0
0.7236073017120361;-0.5257253050804138;-0.44721952080726624
-0.276388019323349;-0.8506492376327515;-0.4472198486328125
-0.8944262266159058;0.0;-0.44721561670303345
-0.276388019323349;0.8506492376327515;-0.4472198486328125
0.7236073017120361;0.5257253050804138;-0.44721952080726624
0.276388019323349;-0.8506492376327515;0.4472198486328125
-0.7236073017120361;-0.5257253050804138;0.44721952080726624
-0.7236073017120361;0.5257253050804138;0.44721952080726624
0.276388019323349;0.8506492376327515;0.4472198486328125
0.8944262266159058;0.0;0.44721561670303345
0.0;0.0;1.0
-0.16245555877685547;-0.49999526143074036;-0.8506544232368469
0.42532268166542053;-0.30901139974594116;-0.8506541848182678
0.26286882162094116;-0.8090116381645203;-0.5257376432418823
0.8506478667259216;0.0;-0.5257359147071838
0.42532268166542053;0.30901139974594116;-0.8506541848182678
-0.525729775428772;0.0;-0.8506516814231873
-0.6881893873214722;-0.49999693036079407;-0.5257362127304077
-0.16245555877685547;0.49999526143074036;-0.8506544232368469
-0.6881893873214722;0.49999693036079407;-0.5257362127304077
0.26286882162094116;0.8090116381645203;-0.5257376432418823
0.9510578513145447;-0.30901262164115906;0.0
0.9510578513145447;0.30901262164115906;0.0
0.0;-0.9999999403953552;0.0
0.5877856016159058;-0.8090167045593262;0.0
-0.9510578513145447;-0.30901262164115906;0.0
-0.5877856016159058;-0.8090167045593262;0.0
-0.5877856016159058;0.8090167045593262;0.0
-0.9510578513145447;0.30901262164115906;0.0
0.5877856016159058;0.8090167045593262;0.0
0.0;0.9999999403953552;0.0
0.6881893873214722;-0.49999693036079407;0.5257362127304077
-0.26286882162094116;-0.8090116381645203;0.5257376432418823
-0.8506478667259216;0.0;0.5257359147071838
-0.26286882162094116;0.8090116381645203;0.5257376432418823
0.6881893873214722;0.49999693036079407;0.5257362127304077
0.16245555877685547;-0.49999526143074036;0.8506543636322021
0.525729775428772;0.0;0.8506516814231873
-0.42532268166542053;-0.30901139974594116;0.8506541848182678
-0.42532268166542053;0.30901139974594116;0.8506541848182678
0.16245555877685547;0.49999526143074036;0.8506543636322021
| improve this answer | |
$\endgroup$
  • $\begingroup$ I get an error: AttributeError: 'NoneType' object has no attribute 'data' $\endgroup$ – Peter H. Apr 30 '16 at 17:28
  • $\begingroup$ That means the object is not selected. $\endgroup$ – TLousky Apr 30 '16 at 17:30
  • $\begingroup$ I also have added the .3ds file into my question which I import into blender $\endgroup$ – Peter H. Apr 30 '16 at 17:31
  • $\begingroup$ OK, I just ran it once more and I got the coordinates, but all of have have the same value in the 2. colomn which means I get the wrong values $\endgroup$ – Peter H. Apr 30 '16 at 17:34
  • $\begingroup$ Hmm. I'll have a go at it with your 3ds file when I get back home later. $\endgroup$ – TLousky Apr 30 '16 at 17:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.