export coordinates to CSV
For a school-project I would like to get the xyz coordinates of all vertices from my Maxscene into an excel-spreadsheet( .csv ) Wich would preferably look something like this:
1410,4580,93
1629,5098,123
1854,5284,70 etc...
Can anybody help me with a maxscript that can do this? Thanks in advance,
Robert-Hein Hooijmans
Comments
coordinats numbers problem
We found the script you wrote below, it works without any problems but the output of the "vert.y" is; "4.55203e + 06".
We want to print this as 45111.0. How do we fix the code?
We separated each part of a building and sent it to the 3DMax environment.
MacroScript vertexToCSV category:"bernielomax CSV"
(
out_filename= getSaveFileName caption:"SAVE WHERE" initialDir:"$export" filename:"dope.csv"
out_file = createFile out_filename
for obj in geometry do (
tmesh = snapshotAsMesh obj
format "Obj Name:%\n" obj.name to:out_file --Comment these out if you don´t wanna to see them in your excel
format "X Pos, Y Pos, Z Pos\n" to:out_file --Comment these out if you don´t wanna to see them in your excel
for v = 1 to getNumVerts obj do
(
vert = getVert tmesh v
format "%, %, %\n " vert.x vert.y vert.z to:out_file
)
delete tmesh
)
close out_file
edit out_filename
)
Thanks Bernie
Thanks Bernie
It's very useful for me.
--
CG Generalist
hey robert try this
hey robert try this out:
hugs bern
Vertex Order
Hi Bern,
nice script! Could you tell me which order is used to collect the vertex coordinates?
Thanks in advance.
Best,
V.R.
.
The index of vertices is used. The script start from vertex 1 and continues to the last vertex.
Create a box, convert it to editable poly, then select one vertex. In the MOdify Panel, below the Preview Selection convtols, you will see the index of the vertex. For example, there you can see "Vertex 6 is selected".
Tools and Scripts for Autodesk 3dsMax