我正在完成本教程:https :
//docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html
我从教程中复制了下面的脚本,当我运行脚本时,它编译没有任何错误。我应该能够在操作员搜索菜单 ( F3) 中搜索“按一个移动 X”来执行操作员,但它没有显示在操作员搜索菜单中。如何让操作员显示在搜索菜单中?Blender 2.9 有什么变化吗?
bl_info = {
"name": "Move X Axis",
"category": "Object"
}
import bpy
class ObjectMoveX(bpy.types.Operator):
bl_idname = "object.move_x"
bl_label = "Move X by One"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = context.scene
for obj in scene.objects:
obj.location.x += 1.0
return {'FINISHED'}
def register():
bpy.utils.register_class(ObjectMoveX)
def unregister():
bpy.utils.unregister_class(ObjectMoveX)
if __name__ == "__main__":
register()
Run Code Online (Sandbox Code Playgroud) 请进行健康检查!
我想包括不正确的函数调用返回的确切消息时,了解意外测试失败match的参数pytest.raises()。
文档状态:
match – 如果指定,则断言异常与文本或正则表达式匹配
下面的 repl 中的指令序列几乎说明了一切,但由于某种原因,最后一个测试失败了。
PS C:\Users\peter_000\OneDrive\git\test> pipenv run python
Loading .env environment variables…
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>> import pytest
>>> pytest.__version__
'4.4.1'
>>>
>>> with pytest.raises(TypeError, match='a string'):
... raise TypeError('a string') # passes
...
>>> def func():
... pass
...
>>> func(None)
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud) 我的项目有这个结构:
root
|____Makefile
|
|___src
| |____*.cpp
|
|___includes
| |___*.h
|
|___obj
|___tmp
|___bin
Run Code Online (Sandbox Code Playgroud)
问题是,当我尝试使我收到此错误时:
g++ -std=c++11 obj/book.o -o bin/main
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我的 main.cpp 位于 src 内,而不是我有一个文件 .h,我在其中声明了一个结构和一些函数以及一个 .cpp,我在其中定义了所有内容。在主要和 cpp 我做
root
|____Makefile
|
|___src
| |____*.cpp
|
|___includes
| |___*.h
|
|___obj
|___tmp
|___bin
Run Code Online (Sandbox Code Playgroud)
我如何编译和解决这个问题?这是我的生成文件:
CXX …Run Code Online (Sandbox Code Playgroud)