12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ついに pip に bpy が来た

Last updated at Posted at 2022-12-14

Blender-3.4 で、自前ビルドが必要だった bpy が pip に来ました。

bpy 3.4.0 is available on PyPi, and can be installed through pip install bpy.

python-3.10 のみの提供のようです。

Note that this requires Python 3.10

install

> pip install bpy

使用例

最初はいつもの、Camera, Cube, Light の初期状態です。

import bpy

o = bpy.context.active_object
print(o)

ロードする

blend

bpy.ops.wm.open_mainfile(filepath=BLEND_PATH)

bvh

ret = bpy.ops.import_anim.bvh(  # type: ignore
    filepath=BVH_PATH,
    use_fps_scale=True,
    update_scene_duration=True,)
if ret != FINISHED:
    raise Exception()

rendering する

EEVEE

import bpy
# bpy.context.scene.render.engine = 'CYCLES' # EEVEE動くようです
bpy.ops.render.render()
bpy.data.images['Render Result'].save_render(filepath='image.png')

object にアクセスする

active = bpy.context.active_object
print(active)
for o in bpy.data.objects:
  print(o)
12
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?