目标

  • [x] 总结Blender插件初始化范例

总结

插件模板

Blender内部插件实现方式模板功能总结如下:

  1. 定义了子模块重加载方式
  2. 定义了批量加载子模块的方式
  3. 插件注册函数
  4. 插件注销函数

模块总体结构如下:

# 支持子模块重加载(support reloading sub-modules)
if "bpy" in locals():
from importlib import reload
_modules_loaded[:] = [reload(val) for val in _modules_loaded]
del reload # 定义要加载的模块
_modules = [
"add_mesh_torus",
...
] import bpy # 模块加载, __import__()相当于 from __name__ import _modules
__import__(name=__name__, fromlist=_modules)
_namespace = globals()
_modules_loaded = [_namespace[name] for name in _modules]
del _namespace def register():
from bpy.utils import register_class
for mod in _modules_loaded:
for cls in mod.classes:
register_class(cls) def unregister():
from bpy.utils import unregister_class
for mod in reversed(_modules_loaded):
for cls in reversed(mod.classes):
if cls.is_registered:
unregister_class(cls)

范例

Blender Foundation\Blender\2.79\scripts\startup\bl_operators\__init__.py


# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK ##### # <pep8 compliant> # support reloading sub-modules
if "bpy" in locals():
from importlib import reload
_modules_loaded[:] = [reload(val) for val in _modules_loaded]
del reload _modules = [
"add_mesh_torus",
"anim",
"clip",
"console",
"file",
"image",
"mask",
"mesh",
"node",
"object_align",
"object",
"object_randomize_transform",
"object_quick_effects",
"presets",
"rigidbody",
"screen_play_rendered_anim",
"sequencer",
"uvcalc_follow_active",
"uvcalc_lightmap",
"uvcalc_smart_project",
"vertexpaint_dirt",
"view3d",
"wm",
] import bpy if bpy.app.build_options.freestyle:
_modules.append("freestyle") __import__(name=__name__, fromlist=_modules)
_namespace = globals()
_modules_loaded = [_namespace[name] for name in _modules]
del _namespace def register():
from bpy.utils import register_class
for mod in _modules_loaded:
for cls in mod.classes:
register_class(cls) def unregister():
from bpy.utils import unregister_class
for mod in reversed(_modules_loaded):
for cls in reversed(mod.classes):
if cls.is_registered:
unregister_class(cls)

Blender插件初始化范例的更多相关文章

  1. WordPress Tweet Blender插件跨站脚本漏洞

    漏洞名称: WordPress Tweet Blender插件跨站脚本漏洞 CNNVD编号: CNNVD-201310-645 发布时间: 2013-10-30 更新时间: 2013-10-30 危害 ...

  2. Blender插件加载研究

    目标 [x] 解析Blender插件代码加载原理, 为测试做准备 结论 采用方法3的方式, 可以在测试中保证重新加载子模块, 是想要的方式, 代码如下: _qk_locals = locals() d ...

  3. Blender插件编写指南

    前言 Blender插件是Blender的利器, 用户可以使用各种插件扩充Blender的功能. Blender Python插件以bpy.props, bpy.types.Operator, bpy ...

  4. Blender插件之Panel

    目标 [x] 总结Blender之Panel 总结 Blender之Panel需要从Blender界面组成开始理解. 直观上Blender的界面层次为 Editors ‣ Regions ‣ (Tab ...

  5. Blender 插件整理

    系统自带插件列表: 好用的第三方插件: Align Vertices to Grease Pencil, 对齐顶点到蜡笔,   https://blenderartists.org/t/addon-a ...

  6. Blender插件之操作器(Operator)实战

    前言 在Blender中, 操作器(Operator)是它的核心. 用户通过各种操作器来创建和操作场景中的物体. 操作器对象继承自 class bpy.types.Operator(bpy_struc ...

  7. scroll滚动条插件初始化问题

    一种特殊场景下是滚动条容器先隐藏,点击某个东西后显示出来.然后实例化滚动条.实例 js: var flag = true; document.getElementById('btn1').onclic ...

  8. distpicker省市区插件初始化选中值的问题

    $('#distpicker1').distpicker('destroy')  //当需要重新生成的时候,需要先销毁 $('#distpicker1').distpicker({ province: ...

  9. 分页插件--根据Bootstrap Paginator改写的js插件

    刚刚出来实习,之前实习的公司有一个分页插件,和后端的数据字典约定好了的,基本上是看不到内部是怎么实现的,新公司是做WPF的,好像对于ASP.NET的东西不多,导师扔了一个小系统给我和另一个同事,指了两 ...

随机推荐

  1. if判断,while循环,for循环

    if判断 if判断其实就是让计算机模拟人的判断 if if 条件: 代码1 代码2 代码3 ... # 代码块(同一缩进级别的代码,例如代码1.代码2和代码3是相同缩进的代码,这三个代码组合在一起就是 ...

  2. js常用方法和技巧

    随着AJAX的流行,js又得到了很多人的重视,js最大的优势就是它能够对html上的所有元素进行操作,包括创建标签元素,更改元素属性等,这样就使得我们能够利用js来实现很多的动态效果,来提供给用户更强 ...

  3. Ansible 利用playbook批量部署mariadb

    环境说一下 192.168.30.21     ansible 192.168.30.25     client1 192.168.30.26     client2 这里我的ansible环境已经部 ...

  4. BZOJ 2850: 巧克力王国 KDtree + 估价函数

    Code: #include<bits/stdc++.h> #define maxn 100000 #define inf 1000000008 #define mid ((l+r)> ...

  5. 码书:编码与解码的战争 PDF 下载

    码书:编码与解码的战争 PDF 下载 下载地址:https://pan.baidu.com/s/14Y_krHh-unOv4g2KYFFDgQ 如需分享码:[打开微信]->[扫描右侧二维码]-& ...

  6. Django - 内容总结(1)

    内容整理: 1.创建django工程名称 django-admin startproject 工程名 2.创建app cd 工程名 python manage.py startapp cmdb 3.静 ...

  7. Python ---- KMP(博文推荐+代码)

    既解决完后宫问题(八皇后问题)后,又利用半天的时间完成了著名的“看毛片”算法——KMP.对于初学者来说这绝对是个大坑,非常难以理解. 在此,向提出KMP算法的三位大佬表示诚挚的敬意.!!!牛X!!! ...

  8. java ArrayList去重复值

    public static List removeDuplicateWithOrder(List list) { Set set = new HashSet(); List newList = new ...

  9. soui edit passwrod模式下禁用输入法

    一直在用soui做客户端界面,今天发现密码edit在中文输入法下不能输入密码.我在想难道不是这样吗,密码就该用英文输入法啊. 然后我就用mfc的做了个demo,发现mfc的edit在密码模式下是可以用 ...

  10. 基础命令history

    history   记录历史命令 环境变量: HISTSIZE: 命令历史记录的条数: HISTFILE:  命令历史记录的文件,~/.bash_history: HISTFILESIZE: 命令历史 ...