我想创建一个带有一些按钮的弹出窗口。代码如下:
import bpy
class MaxFloater(bpy.types.Operator):
"""Tooltip"""
bl_idname = "view3d.max_floater"
bl_label = "MAX Floater"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width = 400)
def draw(self, context):
row = self.layout.row()
row.operator("mesh.primitive_cube_add")
row.operator("object.modifier_add", text="MIRROR").type='MIRROR'
def register():
bpy.utils.register_class(MaxFloater)
def unregister():
bpy.utils.unregister_class(MaxFloater)
if __name__ == "__main__":
register()
一切正常,只是它希望选择某个对象,或者存在最后一个选定的对象。如果该对象被删除,则该操作符不起作用。(并且不会出现在操作员搜索窗口中)。我不明白为什么会这样?这是view3d操作符,不是对象操作符,不是吗
我想我找到了支撑者的解决方案。此字符串应位于轮询函数中:
它检查当前活动视图是否为三维视图,如果不是,则操作员将无法工作
相关问题 更多 >
编程相关推荐