Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用多个文件夹制作blender插件?_Python_Blender - Fatal编程技术网

Python 如何使用多个文件夹制作blender插件?

Python 如何使用多个文件夹制作blender插件?,python,blender,Python,Blender,我想用Python制作blender插件,但是只使用一个文件会变得非常拥挤。有没有一种方法可以让它包含多个文件夹和所有很酷的东西?(来自) 按如下方式组织文件夹结构: myaddon/ ├── __init__.py ├── operators/ ├── first_operator.py 在\uuuu init\uuuuu.py中,执行以下操作: import bpy from .operators.first_operator import FirstOperator bl_i

我想用Python制作blender插件,但是只使用一个文件会变得非常拥挤。有没有一种方法可以让它包含多个文件夹和所有很酷的东西?

(来自)

按如下方式组织文件夹结构:

myaddon/
├── __init__.py
├── operators/
    ├── first_operator.py
\uuuu init\uuuuu.py
中,执行以下操作:

import bpy

from .operators.first_operator import FirstOperator

bl_info = {
    "name": "MyAddon",
    "description": "A demo addon",
    "author": "myname",
    "version": (1, 0, 0),
    "blender": (2, 7, 9),
    "wiki_url": "my github url here",
    "tracker_url": "my github url here/issues",
    "category": "Animation"
}

def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)
操作符/first_operator.py
文件中,执行以下操作:

import bpy

class FirstOperator(bpy.types.Operator):
    bl_label = "First Operator"
    bl_idname = "myaddon.first_operator"
    bl_description = "A demo operator"
    
    def execute(self, context):
        print("hello world")
        
        return {"FINISHED"}
你必须安装插件才能使用它。您不能仅从Blender中的文本编辑器运行
\uuuuu init\uuuuuuuuuy.py
,使其正常工作



如果您要走这条路,我强烈建议您使用Visual Studio代码和“Blender Development”扩展,这是一种令人惊奇的方法,它消除了每次更改时手动加载/重新加载扩展的所有麻烦。

如果答案解决了您的问题,您能批准它吗?:)我会的,但我没有足够的声誉(哎呀,我不知道我能检查一下复选标记。)