繁体   English   中英

如何在搅拌机中为对象添加位置限制?

[英]how to add location constraints for an object in blender?

我要使它停止运行,并且如果某个对象进入搅拌机中平面的负z部分,则打印对象将超出范围。 对象名称为Cube.031。 我会用sudo代码编写我想做的事情,只是不确定如何确定语法。

 if(Cube.031.zLocation < 0)
        print(object is out of bounds)
        end

如果您知道一些编程知识,那么学习python就不会花很长时间。

对于特定于Blender的信息,几乎所有内容都可以通过bpy模块访问, API参考为online

您可以在bpy.data.objects[]按名称引用对象。 还有其他可用列表,例如bpy.context.selected_objects[]bpy.context.visible_objects[]

对象位置是由三个值(x,y,z)组成的数组,您可以将z位置作为location.zlocation[2]

import bpy

obj = bpy.data.objects['Cube.031']

if obj.location.z < 0:
    print('object is out of bounds')

如果要浏览所有选定的对象

for obj in bpy.context.selected_objects:
    if obj.location.z < 0:
        print('object {} is out of bounds'.format(obj.name))

请注意,v2.80即将发布,并对API进行了一些更改,如果您只是从Blender开始,则可能要从2.80开始。 您还将发现blender.stackexchange是寻求搅拌器特定帮助的更好场所。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM