Вход/Регистрация
Введение в написание скриптов на Питоне для Блендера 2.5x. Примеры кода
вернуться

Larsson Thomas

Шрифт:

row = layout.row

row.alignment = 'RIGHT'

row.operator("my.button", text="8").row=3

row.operator("my.button", text="9", icon='SCENE').row=3

row.operator("my.button", text="10", icon='BRUSH_INFLATE').row=3

layout.label("Fourth row", icon='ACTION')

row = layout.row box = row.box

box.operator("my.button", text="11", emboss=False).loc="4 11"

box.operator("my.button", text="12", emboss=False).loc="4 12"

col = row.column subrow = col.row

subrow.operator("my.button", text="13").loc="4 13"

subrow.operator("my.button", text="14").loc="4 14"

subrow = col.row(align=True)

subrow.operator("my.button", text="15").loc="4 15"

subrow.operator("my.button", text="16").loc="4 16"

box = row.box box.operator("my.button", text="17").number=17

box.separator

box.operator("my.button", text="18")

box.operator("my.button", text="19")

layout.label("Fifth row")

row = layout.row split = row.split(percentage=0.25)

col = split.column

col.operator("my.button", text="21").loc="5 21"

col.operator("my.button", text="22")

split = split.split(percentage=0.3)

col = split.column

col.operator("my.button", text="23")

split = split.split(percentage=0.5)

col = split.column

col.operator("my.button", text="24")

col.operator("my.button", text="25")

# Кнопка

class OBJECT_OT_Button(bpy.types.Operator):

bl_idname = "my.button"

bl_label = "Button" number = bpy.props.IntProperty

row = bpy.props.IntProperty

loc = bpy.props.StringProperty

def execute(self, context):

if self.loc:

words = self.loc.split

self.row = int(words[0])

self.number = int(words[1])

print("Row %d button %d" % (self.row, self.number))

return{'FINISHED'}

# Регистрация

bpy.utils.register_module(__name__)

Панель свойств

Свойства обсуждались в разделе Свойства, но мы не объяснили, как отображать заказные свойства на панели. Этот скрипт как раз делает это. RNA-свойство отображается синтаксисом

layout.prop(ob, 'myRnaInt')

ID-свойства отображаются с помощью

layout.prop(ob, '["myRnaInt"]')

Заметьте, что панель регистрируется явно с помощью

bpy.utils.register_class(MyPropPanel)
вместо использования register_module, который регистрирует всё. Какой метод использовать, не имеет значения в этом примере, поскольку
MyPropPanel
– единственное, что нужно зарегистрировать.

#----------------------------------------------------------

# File panel_props.py

#----------------------------------------------------------

import bpy

from bpy.props import *

# Очистка сцены и создание нескольких объектов

bpy.ops.object.select_by_type(type='MESH')

bpy.ops.object.delete

bpy.ops.mesh.primitive_cube_add(location=(-3,0,0))

cube = bpy.context.object

bpy.ops.mesh.primitive_cylinder_add(location=(0,0,0))

cyl = bpy.context.object

bpy.ops.mesh.primitive_uv_sphere_add(location=(3,0,0))

sphere = bpy.context.object

# Определение RNA-
свойств для каждого объекта

  • Читать дальше
  • 1
  • ...
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • ...

Ебукер (ebooker) – онлайн-библиотека на русском языке. Книги доступны онлайн, без утомительной регистрации. Огромный выбор и удобный дизайн, позволяющий читать без проблем. Добавляйте сайт в закладки! Все произведения загружаются пользователями: если считаете, что ваши авторские права нарушены – используйте форму обратной связи.

Полезные ссылки

  • Моя полка

Контакты

  • chitat.ebooker@gmail.com

Подпишитесь на рассылку: