<?xml version="1.0" encoding="UTF-8" ?>
<rss version="0.91">
  <channel>
    <title>blender-scriptメモ</title>
    <description></description>
    <link>http://blenderscript.ni-moe.com/</link>
    <language>ja</language>
    <copyright>Copyright (C) NINJATOOLS ALL RIGHTS RESERVED.</copyright>

    <item>
      <title>prop_searchの使い方</title>
      <description>prop_searchによるドロップダウンUIの作成方法をまとめてみました。 &lt;img alt=&quot;&quot; src=&quot;http://file.blenderscript.ni-moe.com/prop_search.png&quot; /&gt; &lt;br /&gt;
普段目にするオブジェクトを選択するときに使うコントロールです。&lt;br /&gt;
&lt;br /&gt;

&lt;pre&gt;row.prop_search(tps, &quot;sel_obj&quot;, context.scene, &quot;objects&quot;, text=&quot;Objects&quot;)
&lt;/pre&gt;
基本的にはCollectionPropertyと選択しているオブジェクトの名前を格納するプロパティを指定します。&lt;br /&gt;
上記例では、context.scene.objectsがCollectionなので、そのままプロパティとして渡すことができます。&lt;br /&gt;
&lt;br /&gt;
必要があれば、自分でCollectionPropertyを定義して、そこから選択できるようにすることも出来ました。
&lt;pre&gt;class StringValGroup(bpy.types.PropertyGroup):
    string_val = bpy.props.StringProperty()

class TestPropSearchProps(bpy.types.PropertyGroup):
    string_val_list = bpy.props.CollectionProperty(type=bpy.types.StringValGroup)
&lt;/pre&gt;
PropertyGroupにいろいろな情報を持たせていけばいろいろ便利なことができそうです。&lt;hr /&gt;&lt;br /&gt;

&lt;pre class=&quot;source_code&quot;&gt;# -*- coding: utf-8 -*-

import bmesh
import bpy
from bpy_extras import view3d_utils



class StringValGroup(bpy.types.PropertyGroup):
    string_val = bpy.props.StringProperty()

bpy.utils.register_class(StringValGroup)

#-----------------------------

class TestPropSearchProps(bpy.types.PropertyGroup):
    
    # リストで選択されているオブジェクトの名前
    sel_obj = bpy.props.StringProperty()
    
    # Drop Downリストに表示される値のリスト
    string_val_list = bpy.props.CollectionProperty(type=bpy.types.StringValGroup)
    
    # 選択されている値が格納されるプロパティ
    sel_string = bpy.props.StringProperty()
    sel_string_val = bpy.props.StringProperty()
    
    def init_val_list(self):
        self.string_val_list.clear()
        for i in range(10):
            v = self.string_val_list.add()
            v.string_val = &quot;val&quot; + str( i )
            v.name = &quot;name&quot; + str(i) 
    
    def update_val(self, nm):
        for sv in self.string_val_list:
            if sv.name == nm:
                self.sel_string_val = sv.string_val



class TestPropSearchPanel(bpy.types.Panel):
    bl_label = &quot;TestPropSearch&quot;
    bl_idname = &quot;OBJECT_PT_rename&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_description = &quot;Rename Tools&quot;
    bl_context = &quot;object&quot;
    
    def draw(self, context):
        
        tps = context.window_manager.test_prop_search

        layout = self.layout
        row = layout.row()
        row.prop_search(tps, &quot;sel_obj&quot;, context.scene, &quot;objects&quot;, text=&quot;Objects&quot;)
        row = layout.row()
        row.prop(tps, &quot;sel_obj&quot;)
        
        tps.init_val_list()
        row = layout.row()
        row.prop_search(tps, &quot;sel_string&quot;, tps, &quot;string_val_list&quot;, text=&quot;Test&quot;)
        row = layout.row()
        row.prop(tps, &quot;sel_string&quot;)
        
        tps.update_val(tps.sel_string)
        row.prop(tps, &quot;sel_string_val&quot;)
        
        

def register():

    bpy.utils.register_class(TestPropSearchProps)
    bpy.utils.register_class(TestPropSearchPanel)
    
    bpy.types.WindowManager.test_prop_search = bpy.props.PointerProperty(\
        type = TestPropSearchProps)
    
def unregister():
    bpy.utils.unregister_class(StringValGroup)
    bpy.utils.unregister_class(TestPropSearchProps)
    bpy.utils.unregister_class(TestPropSearchPanel)
    
if __name__ == &quot;__main__&quot;:
    register()
&lt;/pre&gt;</description> 
      <link>http://blenderscript.ni-moe.com/blenderscript/prop_search%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9</link> 
    </item>
    <item>
      <title>BlenderのScriptについての備忘録</title>
      <description>BlenderのPythonスクリプトに関する情報をメインにまとめていきます。&lt;br /&gt;
調べながら、試行錯誤しながらですので、拙い部分があるとは思いますが、&lt;br /&gt;
よろしくお願いします。&lt;br /&gt;
</description> 
      <link>http://blenderscript.ni-moe.com/blenderscript/blender%E3%81%AEscript%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E3%81%AE%E5%82%99%E5%BF%98%E9%8C%B2</link> 
    </item>

  </channel>
</rss>