[Blender3.3] 日本の地形モデルメッシュ追加アドオンの開発 (7): 独自アイコンの指定
![イメージ](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFzT2yxBpWmVLV-xUrT_P03G-4CdWjGntjYC1H80ysKdv-TO5XeKY8vZGu7Afm6siSw6fk5m-v1UgScvWo6v3Mnft6kpIRWGf3E68vYe8y1wIVduqil4Q8y8cbkwhdVc9B-lpZ3tGRwo9agTsJUiE1Z8JZtbw8rQfwo7q4xzu0vRWxHTAlhhX0P17p-w/w53-h53/TM_MESH_TERRAIN.png)
前回 までで一応動作するものになりましたが、改良の余地は沢山あります。 それらも一つ一つ調べながらやらないとなので、時間がかかりそうです。 さて、今回は追加メニューで表示するアイコンを独自のものに変えてみたいと思います。 最初にアイコンを作成します。 アイコンのサイズは縦横とも32ピクセルです。他のメニューに合わせて背景を黒、描画色を白にしました。TM_MESH_TERRAIN.png の名前でPNG形式で保存しておきます。 次に作るのは、読み込み用のモジュールです。icon.py としました。内容は下記の通りです。 # -*- coding: utf-8 -*- # # package: terrain_model # file: icon.py import os import bpy from trace import Trace # We can store multiple preview collections here, # however in this example we only store "main" preview_collections = {} def get_icon_id(name): pcoll = preview_collections["custom"] return pcoll[name].icon_id def register(): Trace.print("icon: register()") # Note that preview collections returned by bpy.utils.previews # are regular py objects - you can use them to store custom data. import bpy.utils.previews pcoll = bpy.utils.previews.new() # path to the folder where the icon is # the path is calculated relative to this py file...