Extensions:2.6/Py/Scripts/Add Mesh/Data Surface

提供: wiki
< Extensions:2.6‎ | Py‎ | Scripts‎ | Add Mesh
2018年6月29日 (金) 06:09時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索
Data Surface
Add a mesh from data files (usually generated by other programs)
UI location Group: AddMesh
Usage in 3D View: Shift-A > Mesh > Data Surface
Version 1.1 Author(s) Sun Sibai, Pontiac
Blender 2.71 or later License GPL v2 or later
Distribution Extern
Note(s) Data files contain matrices of x,y,z coordinates of vertices.


Executable information
File name __init__.py & add_mesh_text_data_surface.py
Current version download https://github.com/niasw/add_mesh_DataSurface/archive/master.zip


Links https://github.com/niasw/add_mesh_DataSurface


Introduction

In engineering and science, numerical data sometimes are more common than analytical expressions. Analytical expressions are accurate and easy to accept, but for numerical algorithms (such as self-adapting optimizing) and real experiments (such as measurements with instruments), numerical data are more suitable and more convenient.

If you want to transfer data from numerical algorithms or real experiments into Blender to visualize them, this addon may be your proper choice. In the example I will show below, I turned text data of x,y and z coordinates into a mesh surface.

If you are seeking for addons for analytical expressions, please go to the addon 3D Function Surface.

Installation

To install this addon, please copy all the scripts and data files to the addon path.

Then copy directory add_mesh_DataSurface to Blender addon path. If you don't know where is the addon path, please open your Blender, and run scripts below in the Python Console:

import addon_utils
print(addon_utils.paths())

To enable this addon, please open your Blender.

  • Click Files > User preferences ... > Addons > Add mesh.
  • Find Niasw add mesh DataSurface07.png and click the checkbox (right)

Instructions

There are two modules in this addon:

  • Text Data Surface can create all mesh surface in 3D space. But it needs 3 matrices data:
x=x(u,v)
y=y(u,v)
z=z(u,v)

where x,y,z are coordinates in space and u,v are column and row indices.

  • Z Data Surface can create a subset mesh surface of above. It is convenient for only 1 table data needed:
z=f(x,y)

where x,y data are in form of vector and z data are in form of matrix.


To show how to use this addon, I will give examples.

example for Text Data Surface

  • In the 3D View block, press Shift+a > Mesh > Data surface > Text data surface.

Then a twisted ribbon-like mesh shows.

Niasw add mesh DataSurface01.pngNiasw add mesh DataSurface02.png

The coordinates of vertices are from data files Xdata.txt, Ydata.txt and Zdata.txt.
These data can be generated from Octave/Matlab script example.m.
To change the data files, clicking the browsing buttons (shown right).

Niasw add mesh DataSurface0A.png

As for the loop and flip checkbox, try them to know what they represent. After clicking loop, you should see the figure closed in each Z slice. Yes, the ribbon becomes a tube. After clicking flip, you should see the light effect changed a little. Yes, the normal direction flipped.

Niasw add mesh DataSurface03 1.png Niasw add mesh DataSurface04 1.png Niasw add mesh DataSurface05 1.png
Niasw add mesh DataSurface03 2.png Niasw add mesh DataSurface04 2.png Niasw add mesh DataSurface05 2.png

example for Z Data Surface

  • In the 3D View block, press Shift+a > Mesh > Data surface > Z(x,y) table surface.

Then a floating ribbon-like mesh shows.

Niasw add mesh DataSurface0B.pngNiasw add mesh DataSurface0C.png

The coordinates of vertices are from table data file csvdata.csv.
To change the data files, clicking the browsing button (shown right).
Plain text table is also OK.

Niasw add mesh DataSurface12.png


The structure of the table in .csv file is shown below:

The .csv file can be exported from spreadsheet programs such as Excel and LibreOffice Calc. Niasw add mesh DataSurface13.png

There are 3 boolean options in Z Data Surface. loop and flip are like those in Text Data Surface.

Here shows their effects.

Niasw add mesh DataSurface0D 1.png Niasw add mesh DataSurface0E 1.png Niasw add mesh DataSurface0F 1.png
Niasw add mesh DataSurface0D 2.png Niasw add mesh DataSurface0E 2.png Niasw add mesh DataSurface0F 2.png

The tran option is to switch x axis with y axis. It is the same with transposing the whole data table. By combining tran function and loop function, we can close the surface mesh either in x direction or y direction, shown below:

Niasw add mesh DataSurface10 1.png Niasw add mesh DataSurface11 1.png
Niasw add mesh DataSurface10 2.png Niasw add mesh DataSurface11 2.png
Niasw add mesh DataSurface10 3.png Niasw add mesh DataSurface11 3.png

Notes

If you have further requirements, you can fork the source codes and develop your own one. To know how this addon works, please go to page Text Data Surface and Z Data Surface.

Compatibility

This addon has been tested on Ubuntu 12.04, Blender 2.71a, Python 3.2 (bundled), 32-bit.

It may also work with Blender versions < 2.71, but not tested yet.

Troubleshooting

  • Add-on does not appear on the list.

Check if you have installed this addon. Make sure the ".py" files are in the addon path properly. Make sure you have enabled this addon in User Preferences.


  • Error combining coordinate data: Traceback (most recent call last):
  • ...
  • FileNotFoundError: [Errno 2] No such file or directory: '.../add_mesh_Surface/Xdata.txt'

or

  • Fail to find example data files:
  • I have searched in following paths:
  • .../add_mesh_DataSurface/Xdata.txt

These messages mean Blender did not find the data files. When you downloaded it as a zip file, did you extract the folder as add_mesh_DataSurface instead of the default 'add_mesh_DataSurface-master'? If not, please rename this folder under addon path as add_mesh_DataSurface.


  • Browser Button fails to work ...

Reset it: Delete the current object and re-add it please.

Support

To raise a bug report, you may issue it on here(github-issues), or here(developer.blender.org-task).

To contact with me, please write an email to <niasw(AT)pku.edu.cn>.

Thanks

"makeFaces" method and "create_mesh_and_object" method in add_mesh_text_data_surface.py and add_mesh_z_data_surface.py are from Blender addon add extra objects. Thank Pontiac.

Thank Noel Stoutenburg for suggestions about .csv files and Z Data Surface. Thank @squarednob for issue reporting and testing.

External links

https://github.com/niasw/add_mesh_DataSurface