﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Extensions%3A2.6%2FPy%2FScripts%2FAdd_Mesh%2FData_Surface%2FText_Data_Surface</id>
	<title>Extensions:2.6/Py/Scripts/Add Mesh/Data Surface/Text Data Surface - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Extensions%3A2.6%2FPy%2FScripts%2FAdd_Mesh%2FData_Surface%2FText_Data_Surface"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface/Text_Data_Surface&amp;action=history"/>
	<updated>2026-09-08T17:56:42Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface/Text_Data_Surface&amp;diff=147901&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface/Text_Data_Surface&amp;diff=147901&amp;oldid=prev"/>
		<updated>2018-06-28T21:09:50Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 21:09時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface/Text_Data_Surface&amp;diff=147900&amp;oldid=prev</id>
		<title>2014年8月13日 (水) 04:43にwiki&gt;Niaswによる</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface/Text_Data_Surface&amp;diff=147900&amp;oldid=prev"/>
		<updated>2014-08-13T04:43:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Script Detail ===&lt;br /&gt;
&lt;br /&gt;
This page is to explain how Data Surface addon works.&lt;br /&gt;
&lt;br /&gt;
The key files to this addon are two python scripts: &amp;lt;b&amp;gt;__init__.py&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;add_mesh_text_data_surface.py&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== __init__.py ===&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;b&amp;gt;__init__.py&amp;lt;/b&amp;gt;, these scripts declare the information of this addon.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
bl_info = {&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;3D Surfaces from Data Files&amp;quot;,&lt;br /&gt;
  &amp;quot;author&amp;quot;: &amp;quot;Sun Sibai (niasw) &amp;lt;niasw@pku.edu.cn&amp;gt;, Pontiac&amp;quot;,&lt;br /&gt;
  &amp;quot;version&amp;quot;: (1, 0),&lt;br /&gt;
  &amp;quot;blender&amp;quot;: (2, 71, 0),&lt;br /&gt;
  &amp;quot;location&amp;quot;: &amp;quot;View3D &amp;gt; Add &amp;gt; Mesh&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Create Object using Data Files.&amp;quot;,&lt;br /&gt;
  &amp;quot;wiki_url&amp;quot;: &amp;quot;https://github.com/niasw/add_mesh_DataSurface&amp;quot;,&lt;br /&gt;
  &amp;quot;category&amp;quot;: &amp;quot;Add Mesh&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
these scripts define the menu shown in &amp;lt;b&amp;gt;3D View&amp;lt;/b&amp;gt; when pressing {{Shortcut|Shift+A}}.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class INFO_MT_mesh_data_surface_add(bpy.types.Menu):&lt;br /&gt;
  bl_idname = &amp;quot;INFO_MT_mesh_data_surface_add&amp;quot;&lt;br /&gt;
  bl_label = &amp;quot;Data Surface&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  def draw(self, context):&lt;br /&gt;
    layout = self.layout&lt;br /&gt;
    layout.operator_context = 'INVOKE_REGION_WIN'&lt;br /&gt;
    layout.operator(&amp;quot;mesh.primitive_text_data_surface&amp;quot;,&lt;br /&gt;
           text=&amp;quot;Text Data Surface&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
def menu_func(self, context):&lt;br /&gt;
  self.layout.menu(&amp;quot;INFO_MT_mesh_data_surface_add&amp;quot;, icon=&amp;quot;PLUGIN&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== add_mesh_text_data_surface.py ===&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;b&amp;gt;add_mesh_text_data_surface.py&amp;lt;/b&amp;gt;, this is the main class.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class AddTextDataSurface(bpy.types.Operator):&lt;br /&gt;
    bl_idname = &amp;quot;mesh.primitive_text_data_surface&amp;quot;&lt;br /&gt;
    bl_label = &amp;quot;Add Text Data Surface&amp;quot;&lt;br /&gt;
    bl_options = {'REGISTER', 'UNDO', 'PRESET'}&lt;br /&gt;
&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
    def execute(self, context):&lt;br /&gt;
        ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When adding the mesh object or editing parameters, &amp;lt;b&amp;gt;execute&amp;lt;/b&amp;gt; method will be called for each operation.&lt;br /&gt;
&lt;br /&gt;
The input parameters are also defined in this class.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class AddTextDataSurface(bpy.types.Operator):&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
    xFile = StringProperty(name=&amp;quot;Data File of X(U,V)&amp;quot;,&lt;br /&gt;
        description=&amp;quot;U,V: index coordinates of nodes; X: x coordinate of nodes. (Matrix Text)&amp;quot;,&lt;br /&gt;
        default=addon_utils.paths()[0]+&amp;quot;/add_mesh_DataSurface/Xdata.txt&amp;quot;, subtype=&amp;quot;FILE_PATH&amp;quot;)&lt;br /&gt;
    yFile = StringProperty(name=&amp;quot;Data File of Y(U,V)&amp;quot;,&lt;br /&gt;
        description=&amp;quot;U,V: index coordinates of nodes; Y: y coordinate of nodes. (Matrix Text)&amp;quot;,&lt;br /&gt;
        default=addon_utils.paths()[0]+&amp;quot;/add_mesh_DataSurface/Ydata.txt&amp;quot;, subtype=&amp;quot;FILE_PATH&amp;quot;)&lt;br /&gt;
    zFile = StringProperty(name=&amp;quot;Data File of Z(U,V)&amp;quot;,&lt;br /&gt;
        description=&amp;quot;U,V: index coordinates of nodes; Z: z coordinate of nodes. (Matrix Text)&amp;quot;,&lt;br /&gt;
        default=addon_utils.paths()[0]+&amp;quot;/add_mesh_DataSurface/Zdata.txt&amp;quot;, subtype=&amp;quot;FILE_PATH&amp;quot;)&lt;br /&gt;
    loop = BoolProperty(name=&amp;quot;Loop in U Direction&amp;quot;,&lt;br /&gt;
        description=&amp;quot;Loop in U direction or not?&amp;quot;,&lt;br /&gt;
        default=False)&lt;br /&gt;
    flip = BoolProperty(name=&amp;quot;Flip Normal Vector&amp;quot;,&lt;br /&gt;
        description=&amp;quot;Flip the normal vector of surfaces or not?&amp;quot;,&lt;br /&gt;
        default=False)&lt;br /&gt;
&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When calling the &amp;lt;b&amp;gt;execute&amp;lt;/b&amp;gt;, several auxiliary methods will be called in &amp;lt;b&amp;gt;execute&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The 1st aux-method is to acquire matrix data from text files. The &amp;lt;b&amp;gt;Xdata.txt&amp;lt;/b&amp;gt; in the previous example (on [http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface Data Surface wikipage]) is an instance of these text data files.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Load data from plain text file (in matrix format)&lt;br /&gt;
# Return uNum, vNum, dataList&lt;br /&gt;
#   filename ... plain text file of data (in matrix format)&lt;br /&gt;
#   uNum ... number of vertices in U direction (horizontal in matrix)&lt;br /&gt;
#   vNum ... number of vertices in V direction (veritical in matrix)&lt;br /&gt;
#   dataList ... list of float/double data parsed from text file&lt;br /&gt;
def loadTextData(filename):&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Coordinates will be loaded in after calling &amp;lt;b&amp;gt;loadTextData&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The 2nd aux-method is to make series of faces line by line. (This method is from Blender addon: add extra objects -&amp;gt; 'createFaces' method. Inferred from author declarations in scripts there, it might be written by Pontiac. If I made a mistake here, please tell me.) We have obtained coordinates of vertices. To make vertices, just append the tuple (x,y,z) to the variable &amp;lt;b&amp;gt;verts&amp;lt;/b&amp;gt;. To get &amp;lt;b&amp;gt;faces&amp;lt;/b&amp;gt;, containing the list of indices of faces, this aux-method is really helpful.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Link two lines of vertices&lt;br /&gt;
# Returns the list of the new faces&lt;br /&gt;
#   verts1 ... 1st Line.&lt;br /&gt;
#   verts2 ... 2nd Line.&lt;br /&gt;
#   loop ... Link the final with the start.&lt;br /&gt;
#   flip ... Flip the normal side of faces.&lt;br /&gt;
def makeFaces(verts1, verts2, loop=False, flip=False):&lt;br /&gt;
    ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After we get &amp;lt;b&amp;gt;verts&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;faces&amp;lt;/b&amp;gt;, we can call &amp;lt;b&amp;gt;create_mesh_and_object&amp;lt;/b&amp;gt; to create the target mesh. &amp;lt;b&amp;gt;edges&amp;lt;/b&amp;gt; is not necessary. (This method is from Blender addon: add extra objects -&amp;gt; 'create_mesh_object' method. Inferred from author declarations in scripts there, it might be written by Pontiac. If I made a mistake here, please tell me.)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def create_mesh_and_object(context, verts, edges, faces, name):&lt;br /&gt;
    mesh = bpy.data.meshes.new(name)&lt;br /&gt;
    mesh.from_pydata(verts, edges, faces)&lt;br /&gt;
    mesh.update()&lt;br /&gt;
&lt;br /&gt;
    from bpy_extras import object_utils&lt;br /&gt;
    return object_utils.object_data_add(context, mesh, operator=None)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once we created this mesh, work finished!&lt;br /&gt;
&lt;br /&gt;
=== Thanks ===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;makeFaces&amp;quot; method and &amp;quot;create_mesh_and_object&amp;quot; method are from Blender addon [http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Add_Extra add extra objects]. Thank Pontiac.&lt;br /&gt;
&lt;br /&gt;
If you are still not satisfied, please go to the source scripts.&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
* back to [http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Data_Surface Data Surface]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Niasw</name></author>
		
	</entry>
</feed>