「Dev:JA/Ref/Release Notes/4.40/python api」の版間の差分
(ページの作成:「{{MARKDOWN}} 元記事:[Python API - Blender Developer Documentation](https://developer.blender.org/docs/release_notes/4.4/python_api/) # Blender 4.4: Python API[¶](…」) |
|||
1行目: | 1行目: | ||
− | + | ■2025/03/01(土) 6:33 | |
− | 元記事:[ | + | 元記事:[https://developer.blender.org/docs/release_notes/4.4/python_api/ Python API - Blender Developer Documentation] |
− | + | = Blender 4.4: Python API = | |
− | + | == <span id="breaking-changes"></span> 互換性のなくなる変更 == | |
− | + | === Blender タイプのサブクラス化 === | |
+ | Blender タイプ(`Operator`、`PropertyGroup` など)を元に、自身の `__new__`/`__init__` コンストラクタを定義した Python 定義のクラスは、汎用の位置引数とキーワード引数を渡して[https://docs.blender.org/api/4.4/info_overview.html#construction-destruction 親の対応する関数を呼び出さないといけなくなりました]。 | ||
− | + | <syntaxhighlight lang="python"> | |
− | |||
− | |||
import bpy | import bpy | ||
class AwesomeRaytracer(bpy.types.RenderEngine): | class AwesomeRaytracer(bpy.types.RenderEngine): | ||
17行目: | 16行目: | ||
super().__init__(*args, **kwargs) | super().__init__(*args, **kwargs) | ||
... | ... | ||
− | + | </syntaxhighlight> | |
− | |||
− | |||
− | |||
− | |||
− | + | === Paint === | |
+ | * `paint.brush` と `paint.eraser_brush` が読み込み専用のプロパティになりました。([https://projects.blender.org/blender/blender/commit/9e8c037375b42f7e2376549e55958cb98c4eea4e 9e8c037375]) | ||
− | + | === GPU === | |
− | + | * `POLYLINE_FLAT_COLOR` または `POLYLINE_SMOOTH_COLOR`、`POLYLINE_UNIFORM_COLOR` で描画、もしくは幅が2以上の線を `FLAT_COLOR` または `SMOOTH_COLOR`、`UNIFORM_COLOR` で描いた場合、下記のルールが適用されるようになりました。 | |
− | + | ** `pos` 属性は `F32` 形式の `FLOAT` フェッチタイプを使用すること。 | |
− | + | ** `color` 属性は `F32` 形式の `FLOAT` フェッチタイプ'''または''' '''4コンポーネント'''の `U8` と、フェッチモードに `INT_TO_FLOAT_UNIT` を使用すること。 | |
− | + | ** 各属性は4バイトで揃える必要があります。 | |
− | + | ** プリミティブタイプは `GPU_PRIM_LINES` または `GPU_PRIM_LINE_STRIP`、`GPU_PRIM_LINE_LOOP` にする必要があります。 | |
− | + | ** インデックスバッファを使用した描画の場合、プリミティブリスタートインデックスを入れてはいけません。 | |
− | + | === Grease Pencil === | |
+ | * Texture Mapping(テクスチャマッピング)モディファイアーの Influence(影響)から、頂点グループを削除しました。([https://projects.blender.org/blender/blender/commit/c452d5d9e807243ade36809b61673f590bdf67f7 c452d5d9e8]) | ||
− | - | + | === Video Sequencer === |
+ | * `bpy.types.Sequence` と関連するすべてのタイプを `bpy.types.Strip` にリネームしました。完全なリストは[[#video-sequencer-strips|下記]]を参照してください。 | ||
− | + | * Text(テキスト)ストリップの `align_x` と `align_y` を `anchor_x` と `anchor_y` にリネーム。プロパティ `alignment_x` は正しく行揃えするように。([https://projects.blender.org/blender/blender/commit/77a5478c0f5460b3284826c5f11f818c26f9823b 77a5478c0f]) | |
− | + | === ユーザーインターフェイス === | |
− | + | * `UILayout.template_icon()` がビルトインのアイコンを通常サイズで表示、ボタンにあわせてスケールが変化しないように。([https://projects.blender.org/blender/blender/commit/1f88645728 1f88645728]) | |
− | + | === Actions === | |
+ | * アクションに [https://developer.blender.org/docs/release_notes/4.4/animation_rigging/#slotted-actions スロット]が付き、アクションの割り当てと編集に変更が必要です。詳しい更新方法は[[#slotted-actions |下記の説明]]をお読みください。 | ||
− | + | == 追加 == | |
− | + | === bpy.app === | |
+ | * 属性 `bpy.app.portable` は、インストールされている Blender がポータブル版かどうかを示し、`WITH_INSTALL_PORTABLE` ビルドオプションと一致します。([https://projects.blender.org/blender/blender/commit/481a8b67d42ce03249b2aa6901630254291cbe65 481a8b67d4]) | ||
− | + | * 属性 `bpy.app.module` は、Blender が Python モジュールとして実行中かどうかを示します。([https://projects.blender.org/blender/blender/commit/a6b293daacb0259b9879b88e33afc0220306a578 a6b293daac]) | |
− | + | === Grease Pencil === | |
+ | * `frame.drawing` プロパティ用のセッターを追加。([https://projects.blender.org/blender/blender/commit/dc6e879d0f45e623151398e34f9a7cc08cb70296 dc6e879d0f]). | ||
+ | ** ドローイングをどこか(他のレイヤーやオブジェクト)からコピーするのに利用可能です:`frame.drawing = other_drawing` | ||
− | + | * 新しいプロパティ `is_expanded` をレイヤーグループに追加([https://projects.blender.org/blender/blender/commit/e5bdfd533bcc7beb1e38d30432492357bd015dcf e5bdfd533b]). そのレイヤーグループがレイヤーツリー UI 内で開いていれば `True` を返します。 | |
− | + | * ドローイングのストロークを並べ替える関数を追加。`drawing.reorder_strokes(new_indices=[...])`。([https://projects.blender.org/blender/blender/commit/a265b591bede2a6cf9cda189bee641cbbe94a5a9 a265b591be]) | |
− | |||
− | + | * `color_tag` 列挙プロパティをレイヤーグループに追加し、カラータグを公開。([https://projects.blender.org/blender/blender/commit/36d69e8491de1002458bc33994e7516e20fa0ebd 36d69e8491]). | |
− | + | * Texture Mapping(テクスチャマッピング)モディファイアーから頂点グループの影響を削除。([https://projects.blender.org/blender/blender/commit/c452d5d9e807243ade36809b61673f590bdf67f7 c452d5d9e8]) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === Curves === | |
+ | * 新しい `Curves.reorder_curves(new_indices=[...])`。カーブを並べ替えます。([https://projects.blender.org/blender/blender/commit/a265b591bede2a6cf9cda189bee641cbbe94a5a9 a265b591be]) | ||
− | + | * 新しい `Curves.set_types()`。カーブタイプを変更します。([https://projects.blender.org/blender/blender/commit/5db88ff2e3457763ceb6090378a5ccc8bb45ab48 5db88ff2e3]) | |
− | |||
− | + | === ノード === | |
+ | * 新しい `Node.color_tag` プロパティ。ノードのカラータグ(Texture、Vector、Output など…)に対応する列挙アイテムを返します。([https://projects.blender.org/blender/blender/commit/6cd33510c33fe17e999f4cadf869fc19a637eecb 6cd33510c3]) | ||
− | + | * 新しい `bl_use_group_interface` プロパティを、カスタムノードツリー用に追加可能に。ノードグループ用の一部のビルトイン UI を無効化できます。([https://projects.blender.org/blender/blender/commit/ebfbc7757b16e7bdfc87272e89584afb8f75a2a4 ebfbc7757b]) | |
− | |||
− | + | == Python モジュールとしての Blender 利用 == | |
+ | PyPI の `bpy` パッケージが、Blender で使用している VFX ライブラリへのアクセスを提供するように。([https://projects.blender.org/blender/blender/pulls/133082 PR#133082]) | ||
− | + | 大半は PyPI で個別のパッケージとして入手可能ですが、Blender と同じバージョンやビルドオプションではない場合があります。この所為で、Blender とデータをやり取りする際にエラーが発生する可能性がありますが、一致するバージョンを使用することで解決できます。 | |
− | + | <syntaxhighlight lang="python"> | |
− | |||
− | |||
import bpy | import bpy | ||
− | # | + | # Blender バンドルの VFX ライブラリを sys.path に追加 |
bpy.utils.expose_bundled_modules() | bpy.utils.expose_bundled_modules() | ||
− | # | + | # 必要なライブラリをインポート |
import pxr | import pxr | ||
import MaterialX | import MaterialX | ||
94行目: | 89行目: | ||
import PyOpenColorIO | import PyOpenColorIO | ||
import pyopenvdb | import pyopenvdb | ||
− | + | </syntaxhighlight> | |
− | + | == <span id="slotted-actions"></span>Slotted Actions(スロット化アクション) == | |
− | + | === 互換性のなくなる変更 === | |
+ | アクションの割り当て(`datablock.animation_data.action = some_action`)は、特定の条件下ではアクションスロットを自動割り当てを行わないため、そのデータブロックがアニメーションされないままになることがあります。 | ||
− | + | アクションの最初のスロットを強制的に割り当てるには、割り当ての後に `datablock.animation_data.action_slot = some_action.slots[0]` を追加します。これは、最初のスロットの `target_id_type` が `UNSPECIFIED` または `datablock.id_type` と同じであることが前提です。この前提は、バージョニングされたアクションのみ有効です。 | |
− | + | {{Note|注意| NLA ストリップまたはアクションコンストレイントへのアクションの割り当てでは、少し動作が違います。`strip.action = some_action` または `constraint.action = some_action` では、常に `target_id_type` と互換性のある最初のスロットが自動で割り当てられます。割り当て後の状態が同じである(アクションがアニメーションする)ため、実際には後方互換性があることになります。}} | |
− | + | === 追記 === | |
+ | スロット化アクションは、アクションを完全にレイヤー化する、進行中の取り組みの一つです。レイヤー化はまだ対応していませんが、データモデルはレイヤーとストリップに対応しています。これは、スロット化アクション用の新しいAPIに反映されています。 | ||
− | + | <syntaxhighlight lang="python"> | |
− | |||
− | |||
import bpy | import bpy | ||
− | # | + | # アクションは以前に作成済み |
action = bpy.data.actions.new("SuzanneAction") | action = bpy.data.actions.new("SuzanneAction") | ||
− | # | + | # スロットの作成は ID タイプと名前が必要 |
slot = action.slots.new(id_type='OBJECT', name="Suzanne") | slot = action.slots.new(id_type='OBJECT', name="Suzanne") | ||
print(f"slot type={slot.target_id_type} name={slot.name_display} identifier={slot.identifier}") | print(f"slot type={slot.target_id_type} name={slot.name_display} identifier={slot.identifier}") | ||
− | # | + | # 出力: |
# slot type=OBJECT name=Suzanne identifier=OBSuzanne | # slot type=OBJECT name=Suzanne identifier=OBSuzanne | ||
− | # F | + | # F カーブとチャンネルグループは単一レイヤーにある無限キーフレームストリップに格納されるように |
layer = action.layers.new("Layer") | layer = action.layers.new("Layer") | ||
strip = layer.strips.new(type='KEYFRAME') | strip = layer.strips.new(type='KEYFRAME') | ||
channelbag = strip.channelbag(slot, ensure=True) | channelbag = strip.channelbag(slot, ensure=True) | ||
− | # F | + | # F カーブとグループは channelbag に以前の `action` と同じ API で作成 |
− | # F | + | # F カーブとグループ自体は今も完全に以前と同じ API |
fcurve = channelbag.fcurves.new("location", index=1) | fcurve = channelbag.fcurves.new("location", index=1) | ||
group = channelbag.groups.new("Object Transform") | group = channelbag.groups.new("Object Transform") | ||
fcurve.group = group | fcurve.group = group | ||
− | # | + | # アクションの割り当ては自動的に Suzanne の ID タイプ+名前と一致するスロットを選択: |
suzanne = bpy.data.objects["Suzanne"] | suzanne = bpy.data.objects["Suzanne"] | ||
anim_data = suzanne.animation_data_create() | anim_data = suzanne.animation_data_create() | ||
anim_data.action = action | anim_data.action = action | ||
− | # | + | # 明示的なスロット割り当てが必要な場合: |
anim_data.action_slot = action.slots[0] | anim_data.action_slot = action.slots[0] | ||
− | # | + | # 複数のスロットがアクションにあり、互換性のある最初の物が欲しい時は |
− | # | + | # 下のコードを使用すること。`anim_data.action_suitable_slots` は、 |
− | # | + | # アクション割り当て後に使用可能。これはそのアクションのアクション |
− | # | + | # スロットのリストだが、中は anim_data のオーナー(ここでは Suzanne) |
+ | # と互換性のある物のみ | ||
anim_data.action_slot = anim_data.action_suitable_slots[0] | anim_data.action_slot = anim_data.action_suitable_slots[0] | ||
− | # | + | # 代わりに 'last_slot_identifier'(最後に使用した識別子)を |
+ | # 設定することで、自動割り当てスロットを決定させることも可能 | ||
anim_data.last_slot_identifier = 'OBDancing Monkey' | anim_data.last_slot_identifier = 'OBDancing Monkey' | ||
anim_data.action = action | anim_data.action = action | ||
print(anim_data.action_slot.identifier) | print(anim_data.action_slot.identifier) | ||
− | # | + | # 出力: OBDancing Monkey, if that slot exists on the Action |
− | + | </syntaxhighlight> | |
− | |||
− | > | ||
− | |||
− | |||
− | + | {{Note|注意|データモデルは複数のレイヤーと、レイヤー毎に複数のストリップを持つことができるようになっていますが、現在、Blender は単一レイヤーと単一キーフレームストリップのみに制限されています。ストリップは無限長で、移動できません。}} | |
− | + | === 廃止予定 === | |
− | + | `Action` タイプの旧関数と属性が 'backward-compatible legacy API'(後方互換性用旧 API) とマークされました。これらはすべて最初のアクションスロットのデータのみ処理を行い、必要ならデータ構造体を作成します。 | |
− | |||
− | |||
− | |||
− | + | {| | |
+ | ! 旧 API !! 新 API | ||
+ | |- | ||
+ | | `action.fcurves` || `action.layers[0].strips[0].channelbag(action.slots[0]).fcurves` | ||
+ | |- | ||
+ | | `action.groups` || `action.layers[0].strips[0].channelbag(action.slots[0]).groups` | ||
+ | |- | ||
+ | | `action.id_root` || `action.slots[0].target_id_type` | ||
+ | |} | ||
− | + | この旧 API は Blender 5.0 で廃止される予定です。 | |
− | |||
− | + | == <span id="video-sequencer-strips"></span>ビデオシーケンサーストリップ == | |
− | + | === 互換性の失われる変更 === | |
+ | タイプ `bpy.types.Sequence` が、関連するタイプもすべて `bpy.types.Strip` にリネームされました。([https://projects.blender.org/blender/blender/commit/d3ba70190b97778943d08ca93f0e2346d09fa1a5 d3ba70190b]) | ||
− | + | 下記はそのフルリストです。 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {| | |
+ | ! 4.3 !! 4.4 | ||
+ | |- | ||
+ | | `bpy.types.Sequence` || `bpy.types.Strip` | ||
+ | |- | ||
+ | | `bpy.types.EffectSequence` || `bpy.types.EffectStrip` | ||
+ | |- | ||
+ | | `bpy.types.AddSequence` || `bpy.types.AddStrip` | ||
+ | |- | ||
+ | |`bpy.types.AdjustmentSequence` || `bpy.types.AdjustmentStrip` | ||
+ | |- | ||
+ | |`bpy.types.AlphaOverSequence` || `bpy.types.AlphaOverStrip` | ||
+ | |- | ||
+ | |`bpy.types.AlphaUnderSequence` || `bpy.types.AlphaUnderStrip` | ||
+ | |- | ||
+ | |`bpy.types.ColorMixSequence` || `bpy.types.ColorMixStrip` | ||
+ | |- | ||
+ | |`bpy.types.ColorSequence` || `bpy.types.ColorStrip` | ||
+ | |- | ||
+ | |`bpy.types.CrossSequence` || `bpy.types.CrossStrip` | ||
+ | |- | ||
+ | |`bpy.types.GammaCrossSequence` || `bpy.types.GammaCrossStrip` | ||
+ | |- | ||
+ | |`bpy.types.GaussianBlurSequence` || `bpy.types.GaussianBlurStrip` | ||
+ | |- | ||
+ | |`bpy.types.GlowSequence` || `bpy.types.GlowStrip` | ||
+ | |- | ||
+ | |`bpy.types.MulticamSequence` || `bpy.types.MulticamStrip` | ||
+ | |- | ||
+ | |`bpy.types.MultiplySequence` || `bpy.types.MultiplyStrip` | ||
+ | |- | ||
+ | |`bpy.types.OverDropSequence` || `bpy.types.OverDropStrip` | ||
+ | |- | ||
+ | |`bpy.types.SpeedControlSequence` || `bpy.types.SpeedControlStrip` | ||
+ | |- | ||
+ | |`bpy.types.SubtractSequence` || `bpy.types.SubtractStrip` | ||
+ | |- | ||
+ | |`bpy.types.TextSequence` || `bpy.types.TextStrip` | ||
+ | |- | ||
+ | |`bpy.types.TransformSequence` || `bpy.types.TransformStrip` | ||
+ | |- | ||
+ | |`bpy.types.WipeSequence` || `bpy.types.WipeStrip` | ||
+ | |- | ||
+ | |`bpy.types.ImageSequence` || `bpy.types.ImageStrip` | ||
+ | |- | ||
+ | |`bpy.types.MaskSequence` || `bpy.types.MaskStrip` | ||
+ | |- | ||
+ | |`bpy.types.MetaSequence` || `bpy.types.MetaStrip` | ||
+ | |- | ||
+ | |`bpy.types.MovieClipSequence` || `bpy.types.MovieClipStrip` | ||
+ | |- | ||
+ | |`bpy.types.MovieSequence` || `bpy.types.MovieStrip` | ||
+ | |- | ||
+ | |`bpy.types.SceneSequence` || `bpy.types.SceneStrip` | ||
+ | |- | ||
+ | |`bpy.types.SoundSequence` || `bpy.types.SoundStrip` | ||
+ | |- | ||
+ | |`bpy.types.SequenceColorBalanceData` || `bpy.types.StripColorBalanceData` | ||
+ | |- | ||
+ | |`bpy.types.SequenceColorBalance` || `bpy.types.StripColorBalance` | ||
+ | |- | ||
+ | |`bpy.types.SequenceCrop` || `bpy.types.StripCrop` | ||
+ | |- | ||
+ | |`bpy.types.SequenceElement` || `bpy.types.StripElement` | ||
+ | |- | ||
+ | |`bpy.types.SequenceElements` || `bpy.types.StripElements` | ||
+ | |- | ||
+ | |`bpy.types.SequenceModifier` || `bpy.types.StripModifier` | ||
+ | |- | ||
+ | |`bpy.types.SequenceModifiers` || `bpy.types.StripModifiers` | ||
+ | |- | ||
+ | |`bpy.types.SequenceProxy` || `bpy.types.StripProxy` | ||
+ | |- | ||
+ | |`bpy.types.SequenceTransform` || `bpy.types.StripTransform` | ||
+ | |- | ||
+ | |`bpy.types.SequencesMeta` || `bpy.types.StripsMeta` | ||
+ | |- | ||
+ | |`bpy.types.SequencesTopLevel` || `bpy.types.StripsTopLevel` | ||
+ | |} | ||
− | + | === 廃止予定 === | |
+ | `bpy.types.Strip`(従来は `bpy.types.Sequence`)を「sequence」として参照するプロパティは廃止予定になり、「strip」に名前を変えた新しいプロパティが追加されました。旧プロパティは5.0まで利用可能ですが、アドオン開発者は新しいプロパティ名を使用するようアドオンを更新することが推奨されます。 | ||
− | | | + | {| |
− | | - | + | ! 廃止予定のプロパティ !! 新しいプロパティ |
− | | `context.active_sequence_strip` | `context.active_strip` | | + | |- |
− | | `context.selected_editable_sequences` | `context.selected_editable_strips` | | + | | `context.active_sequence_strip` || `context.active_strip` |
− | | `context.selected_sequences` | `context.selected_strips` | | + | |- |
− | | `context.sequences` | `context.strips` | | + | |`context.selected_editable_sequences` || `context.selected_editable_strips` |
− | | `SequenceEditor.sequences` | `SequenceEditor.strips` | | + | |- |
− | | `SequenceEditor.sequences_all` | `SequenceEditor.strips_all` | | + | |`context.selected_sequences` || `context.selected_strips` |
− | | `MetaStrip.sequences` | `MetaStrip.strips` | | + | |- |
+ | |`context.sequences` || `context.strips` | ||
+ | |- | ||
+ | |`SequenceEditor.sequences` || `SequenceEditor.strips` | ||
+ | |- | ||
+ | |`SequenceEditor.sequences_all` || `SequenceEditor.strips_all` | ||
+ | |- | ||
+ | |`MetaStrip.sequences` || `MetaStrip.strips` | ||
+ | |} |
2025年3月5日 (水) 04:31時点における版
■2025/03/01(土) 6:33
元記事:Python API - Blender Developer Documentation
目次
[非表示]Blender 4.4: Python API
互換性のなくなる変更
Blender タイプのサブクラス化
Blender タイプ(Operator
、PropertyGroup
など)を元に、自身の __new__
/__init__
コンストラクタを定義した Python 定義のクラスは、汎用の位置引数とキーワード引数を渡して親の対応する関数を呼び出さないといけなくなりました。
import bpy
class AwesomeRaytracer(bpy.types.RenderEngine):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
...
Paint
paint.brush
とpaint.eraser_brush
が読み込み専用のプロパティになりました。(9e8c037375)
GPU
POLYLINE_FLAT_COLOR
またはPOLYLINE_SMOOTH_COLOR
、POLYLINE_UNIFORM_COLOR
で描画、もしくは幅が2以上の線をFLAT_COLOR
またはSMOOTH_COLOR
、UNIFORM_COLOR
で描いた場合、下記のルールが適用されるようになりました。pos
属性はF32
形式のFLOAT
フェッチタイプを使用すること。color
属性はF32
形式のFLOAT
フェッチタイプまたは 4コンポーネントのU8
と、フェッチモードにINT_TO_FLOAT_UNIT
を使用すること。- 各属性は4バイトで揃える必要があります。
- プリミティブタイプは
GPU_PRIM_LINES
またはGPU_PRIM_LINE_STRIP
、GPU_PRIM_LINE_LOOP
にする必要があります。 - インデックスバッファを使用した描画の場合、プリミティブリスタートインデックスを入れてはいけません。
Grease Pencil
- Texture Mapping(テクスチャマッピング)モディファイアーの Influence(影響)から、頂点グループを削除しました。(c452d5d9e8)
Video Sequencer
bpy.types.Sequence
と関連するすべてのタイプをbpy.types.Strip
にリネームしました。完全なリストは下記を参照してください。
- Text(テキスト)ストリップの
align_x
とalign_y
をanchor_x
とanchor_y
にリネーム。プロパティalignment_x
は正しく行揃えするように。(77a5478c0f)
ユーザーインターフェイス
UILayout.template_icon()
がビルトインのアイコンを通常サイズで表示、ボタンにあわせてスケールが変化しないように。(1f88645728)
Actions
追加
bpy.app
- 属性
bpy.app.portable
は、インストールされている Blender がポータブル版かどうかを示し、WITH_INSTALL_PORTABLE
ビルドオプションと一致します。(481a8b67d4)
- 属性
bpy.app.module
は、Blender が Python モジュールとして実行中かどうかを示します。(a6b293daac)
Grease Pencil
frame.drawing
プロパティ用のセッターを追加。(dc6e879d0f).- ドローイングをどこか(他のレイヤーやオブジェクト)からコピーするのに利用可能です:
frame.drawing = other_drawing
- ドローイングをどこか(他のレイヤーやオブジェクト)からコピーするのに利用可能です:
- 新しいプロパティ
is_expanded
をレイヤーグループに追加(e5bdfd533b). そのレイヤーグループがレイヤーツリー UI 内で開いていればTrue
を返します。
- ドローイングのストロークを並べ替える関数を追加。
drawing.reorder_strokes(new_indices=[...])
。(a265b591be)
color_tag
列挙プロパティをレイヤーグループに追加し、カラータグを公開。(36d69e8491).
- Texture Mapping(テクスチャマッピング)モディファイアーから頂点グループの影響を削除。(c452d5d9e8)
Curves
- 新しい
Curves.reorder_curves(new_indices=[...])
。カーブを並べ替えます。(a265b591be)
- 新しい
Curves.set_types()
。カーブタイプを変更します。(5db88ff2e3)
ノード
- 新しい
Node.color_tag
プロパティ。ノードのカラータグ(Texture、Vector、Output など…)に対応する列挙アイテムを返します。(6cd33510c3)
- 新しい
bl_use_group_interface
プロパティを、カスタムノードツリー用に追加可能に。ノードグループ用の一部のビルトイン UI を無効化できます。(ebfbc7757b)
Python モジュールとしての Blender 利用
PyPI の bpy
パッケージが、Blender で使用している VFX ライブラリへのアクセスを提供するように。(PR#133082)
大半は PyPI で個別のパッケージとして入手可能ですが、Blender と同じバージョンやビルドオプションではない場合があります。この所為で、Blender とデータをやり取りする際にエラーが発生する可能性がありますが、一致するバージョンを使用することで解決できます。
import bpy
# Blender バンドルの VFX ライブラリを sys.path に追加
bpy.utils.expose_bundled_modules()
# 必要なライブラリをインポート
import pxr
import MaterialX
import OpenImageIO
import PyOpenColorIO
import pyopenvdb
Slotted Actions(スロット化アクション)
互換性のなくなる変更
アクションの割り当て(datablock.animation_data.action = some_action
)は、特定の条件下ではアクションスロットを自動割り当てを行わないため、そのデータブロックがアニメーションされないままになることがあります。
アクションの最初のスロットを強制的に割り当てるには、割り当ての後に datablock.animation_data.action_slot = some_action.slots[0]
を追加します。これは、最初のスロットの target_id_type
が UNSPECIFIED
または datablock.id_type
と同じであることが前提です。この前提は、バージョニングされたアクションのみ有効です。
注意
NLA ストリップまたはアクションコンストレイントへのアクションの割り当てでは、少し動作が違います。
strip.action = some_action または constraint.action = some_action では、常に target_id_type と互換性のある最初のスロットが自動で割り当てられます。割り当て後の状態が同じである(アクションがアニメーションする)ため、実際には後方互換性があることになります。 |
追記
スロット化アクションは、アクションを完全にレイヤー化する、進行中の取り組みの一つです。レイヤー化はまだ対応していませんが、データモデルはレイヤーとストリップに対応しています。これは、スロット化アクション用の新しいAPIに反映されています。
import bpy
# アクションは以前に作成済み
action = bpy.data.actions.new("SuzanneAction")
# スロットの作成は ID タイプと名前が必要
slot = action.slots.new(id_type='OBJECT', name="Suzanne")
print(f"slot type={slot.target_id_type} name={slot.name_display} identifier={slot.identifier}")
# 出力:
# slot type=OBJECT name=Suzanne identifier=OBSuzanne
# F カーブとチャンネルグループは単一レイヤーにある無限キーフレームストリップに格納されるように
layer = action.layers.new("Layer")
strip = layer.strips.new(type='KEYFRAME')
channelbag = strip.channelbag(slot, ensure=True)
# F カーブとグループは channelbag に以前の `action` と同じ API で作成
# F カーブとグループ自体は今も完全に以前と同じ API
fcurve = channelbag.fcurves.new("location", index=1)
group = channelbag.groups.new("Object Transform")
fcurve.group = group
# アクションの割り当ては自動的に Suzanne の ID タイプ+名前と一致するスロットを選択:
suzanne = bpy.data.objects["Suzanne"]
anim_data = suzanne.animation_data_create()
anim_data.action = action
# 明示的なスロット割り当てが必要な場合:
anim_data.action_slot = action.slots[0]
# 複数のスロットがアクションにあり、互換性のある最初の物が欲しい時は
# 下のコードを使用すること。`anim_data.action_suitable_slots` は、
# アクション割り当て後に使用可能。これはそのアクションのアクション
# スロットのリストだが、中は anim_data のオーナー(ここでは Suzanne)
# と互換性のある物のみ
anim_data.action_slot = anim_data.action_suitable_slots[0]
# 代わりに 'last_slot_identifier'(最後に使用した識別子)を
# 設定することで、自動割り当てスロットを決定させることも可能
anim_data.last_slot_identifier = 'OBDancing Monkey'
anim_data.action = action
print(anim_data.action_slot.identifier)
# 出力: OBDancing Monkey, if that slot exists on the Action
注意
データモデルは複数のレイヤーと、レイヤー毎に複数のストリップを持つことができるようになっていますが、現在、Blender は単一レイヤーと単一キーフレームストリップのみに制限されています。ストリップは無限長で、移動できません。
|
廃止予定
Action
タイプの旧関数と属性が 'backward-compatible legacy API'(後方互換性用旧 API) とマークされました。これらはすべて最初のアクションスロットのデータのみ処理を行い、必要ならデータ構造体を作成します。
旧 API | 新 API |
---|---|
action.fcurves |
action.layers[0].strips[0].channelbag(action.slots[0]).fcurves
|
action.groups |
action.layers[0].strips[0].channelbag(action.slots[0]).groups
|
action.id_root |
action.slots[0].target_id_type
|
この旧 API は Blender 5.0 で廃止される予定です。
ビデオシーケンサーストリップ
互換性の失われる変更
タイプ bpy.types.Sequence
が、関連するタイプもすべて bpy.types.Strip
にリネームされました。(d3ba70190b)
下記はそのフルリストです。
4.3 | 4.4 |
---|---|
bpy.types.Sequence |
bpy.types.Strip
|
bpy.types.EffectSequence |
bpy.types.EffectStrip
|
bpy.types.AddSequence |
bpy.types.AddStrip
|
bpy.types.AdjustmentSequence |
bpy.types.AdjustmentStrip
|
bpy.types.AlphaOverSequence |
bpy.types.AlphaOverStrip
|
bpy.types.AlphaUnderSequence |
bpy.types.AlphaUnderStrip
|
bpy.types.ColorMixSequence |
bpy.types.ColorMixStrip
|
bpy.types.ColorSequence |
bpy.types.ColorStrip
|
bpy.types.CrossSequence |
bpy.types.CrossStrip
|
bpy.types.GammaCrossSequence |
bpy.types.GammaCrossStrip
|
bpy.types.GaussianBlurSequence |
bpy.types.GaussianBlurStrip
|
bpy.types.GlowSequence |
bpy.types.GlowStrip
|
bpy.types.MulticamSequence |
bpy.types.MulticamStrip
|
bpy.types.MultiplySequence |
bpy.types.MultiplyStrip
|
bpy.types.OverDropSequence |
bpy.types.OverDropStrip
|
bpy.types.SpeedControlSequence |
bpy.types.SpeedControlStrip
|
bpy.types.SubtractSequence |
bpy.types.SubtractStrip
|
bpy.types.TextSequence |
bpy.types.TextStrip
|
bpy.types.TransformSequence |
bpy.types.TransformStrip
|
bpy.types.WipeSequence |
bpy.types.WipeStrip
|
bpy.types.ImageSequence |
bpy.types.ImageStrip
|
bpy.types.MaskSequence |
bpy.types.MaskStrip
|
bpy.types.MetaSequence |
bpy.types.MetaStrip
|
bpy.types.MovieClipSequence |
bpy.types.MovieClipStrip
|
bpy.types.MovieSequence |
bpy.types.MovieStrip
|
bpy.types.SceneSequence |
bpy.types.SceneStrip
|
bpy.types.SoundSequence |
bpy.types.SoundStrip
|
bpy.types.SequenceColorBalanceData |
bpy.types.StripColorBalanceData
|
bpy.types.SequenceColorBalance |
bpy.types.StripColorBalance
|
bpy.types.SequenceCrop |
bpy.types.StripCrop
|
bpy.types.SequenceElement |
bpy.types.StripElement
|
bpy.types.SequenceElements |
bpy.types.StripElements
|
bpy.types.SequenceModifier |
bpy.types.StripModifier
|
bpy.types.SequenceModifiers |
bpy.types.StripModifiers
|
bpy.types.SequenceProxy |
bpy.types.StripProxy
|
bpy.types.SequenceTransform |
bpy.types.StripTransform
|
bpy.types.SequencesMeta |
bpy.types.StripsMeta
|
bpy.types.SequencesTopLevel |
bpy.types.StripsTopLevel
|
廃止予定
bpy.types.Strip
(従来は bpy.types.Sequence
)を「sequence」として参照するプロパティは廃止予定になり、「strip」に名前を変えた新しいプロパティが追加されました。旧プロパティは5.0まで利用可能ですが、アドオン開発者は新しいプロパティ名を使用するようアドオンを更新することが推奨されます。
廃止予定のプロパティ | 新しいプロパティ |
---|---|
context.active_sequence_strip |
context.active_strip
|
context.selected_editable_sequences |
context.selected_editable_strips
|
context.selected_sequences |
context.selected_strips
|
context.sequences |
context.strips
|
SequenceEditor.sequences |
SequenceEditor.strips
|
SequenceEditor.sequences_all |
SequenceEditor.strips_all
|
MetaStrip.sequences |
MetaStrip.strips
|