python animation blend,Blender-从python脚本打开并解析.blend文件

I would like to open a .blend file from a python script and parse it (get objects, animations and materials).

The documentation I have read so far about how to do this from blender API (running the script as a blender add-on), but I would like to run this script from the command line without opening blender.

I appreciate all the help you can give me.

解决方案

I realized I don't need to open the binary blender file and parse it in order to use the objects.

Blender has its own python installation, so I put a python script inside the folder path_to_blender/version/scripts/addons , I can execute it in the command line as follows:

blender.exe --background --python ./version/scripts/addons/superScript.py

Next, if you have a .blend file you want to read from your script, put it after the background parameter as follows:

blender.exe --background myFile.blend --python ./version/scripts/addons/superScript.py

And inside your python script do the following:

import bpy

import os

for ob in bpy.context.scene.objects:

print("object name: ", ob.data.name)

In this example I'm printing all the objects inside the scene in the .blend file

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值