How to save mesh data to text

Sometimes it is necessary to save data for creating a mesh (its vertices and polygon indices arrays) to text, for example, for further use in a script or addon.

We can export the mesh to one of the open formats, for example, to *.obj, but if we need only its vertexes and polygons data, we can use the following simple script:

Here we set the file name for saving data, make two arrays with vertexes and polygons data and save them to the specified file.

For example, for the default cube we get the following result:

We can now use this saved data, for example, copying them to a script.

The following script after executing will create a new default cube in the scene:

5 1 vote
Article Rating
Subscribe
Notify of
guest

2 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
John Smith Images Classical

That would be nice if we could change the Index of the vertices in there. I don’t supose there is any way to change the Index, is it.

NikitaD
Admin
2 years ago

You can change indeces if you need. But this will result in mesh fully rebuild.