напиши код для blender который отрывает отдельное окно меню с тримя кнопками
- User
напиши код для blender который отрывает отдельное окно меню с тримя кнопками
- Assistant
import bpy
class SimpleOperator(bpy.types.Operator): bl_idname = "object.simple_operator" bl_label = "Simple Operator"
codedef execute(self, context): print("Button pressed!") return {'FINISHED'}class SimplePanel(bpy.types.Panel): bl_label = "Simple Panel" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_category = 'Tools'
codedef draw(self, context): layout = self.layout row = layout.row() row.operator("object.simple_operator", text="Button 1") row = layout.row() row.operator("object.simple_operator", text="Button 2") row = layout.row() row.operator("object.simple_operator", text="Button 3")def register(): bpy.utils.register_class(SimpleOperator) bpy.utils.register_class(SimplePanel)
def unregister(): bpy.utils.unregister_class(SimpleOperator) bpy.utils.unregister_class(SimplePanel)
if name == "main": register()
- User
напиши код для blender который отрывает отдельное окно меню с тримя кнопками
- Assistant
Для открытия отдельного окна меню в Blender с тремя кнопками можно воспользоваться следующим кодом:
pythonimport bpy from bpy.types import Menu class CustomMenu(Menu): bl_label = "Custom Menu" def draw(self, context): layout = self.layout layout.operator("mesh.primitive_cube_add", text="Add Cube") layout.operator("mesh.primitive_uv_sphere_add", text="Add Sphere") layout.operator("mesh.primitive_cone_add", text="Add Cone") def draw_custom_menu(self, context): self.layout.menu("CustomMenu") def register(): bpy.utils.register_class(CustomMenu) bpy.types.VIEW3D_MT_mesh_add.append(draw_custom_menu) def unregister(): bpy.utils.unregister_class(CustomMenu) bpy.types.VIEW3D_MT_mesh_add.remove(draw_custom_menu) if __name__ == "__main__": register() - User
напиши код для blender который по нажатию кнопки F5 отрывает отдельное окно меню с тримя кнопками
- Assistant
Чтобы создать скрипт в Blender, который открывает отдельное окно меню с тремя кнопками при нажатии кнопки F5, можно воспользоваться следующим кодом:
pythonimport bpy class CustomMenu(bpy.types.Menu): bl_idname = "OBJECT_MT_custom_menu" bl_label = "Custom Menu" def draw(self, context): layout = self.layout layout.operator("mesh.primitive_cube_add", text="Add Cube") layout.operator("mesh.primitive_uv_sphere_add", text="Add Sphere") layout.operator("mesh.primitive_cone_add", text="Add Cone") def register(): bpy.utils.register_class(CustomMenu) wm = bpy.context.window_manager km = wm.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY', region_type='WINDOW') kmi = km.keymap_items.new("wm.call_menu", "F5", "PRESS") kmi.properties.name = "OBJECT_MT_custom_menu" def unregister(): bpy.utils.unregister_class(CustomMenu) if __name__ == "__main__": register()