gpt4 book ai didi

python - 如何在标准 python 控制台中访问 BPY? BPY 是 Blender-python 的东西

转载 作者:太空狗 更新时间:2023-10-29 17:55:09 25 4
gpt4 key购买 nike

作者here第 17.20-17.50 点提到您将来可以使用标准 Python 解释器访问 BPY。它已经 1 岁了,所以我如何使用标准 python 控制台访问 BPY?

Trial 0: roundaround -solution not working with subprocess inside Blender

subprocess.call(['vim', 'test.py'])
# some editing of BPY -file with Vim (not working currently)
subprocess.call(['python', 'test.py'])
# trying to execute the python -file (not working currently)

Trial 1: not working outside Blender

$ cat cubes.py 
import bpy

mylayers = [False]*20
mylayers[0] = True
add_cube = bpy.ops.mesh.primitive_cube_add
for index in range(0, 5):
add_cube(location=(index*3, 0, 0), layers=mylayers)
$ python cubes.py
Traceback (most recent call last):
File "cubes.py", line 1, in <module>
import bpy
ImportError: No module named bpy

最佳答案

基于 these instructions :

获取blender源码:

cd ~/src # or what you prefer
git clone http://git.blender.org/blender.git

cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master

注意依赖关系,参见例如here如果需要* 并通过bpy 目标编译:

cd ~/src/blender
make bpy

如果出现诸如 file INSTALL cannot set permissions on [...] 之类的错误,(重新)以 root 身份运行后者

您的 python 3 现在应该能够import bpy


* 对于 Debian-ish 系统运行

sudo apt-get install subversion build-essential gettext \
libxi-dev libsndfile1-dev \
libpng12-dev libjpeg-dev libfftw3-dev \
libopenexr-dev libopenjpeg-dev \
libopenal-dev libalut-dev libvorbis-dev \
libglu1-mesa-dev libsdl1.2-dev libfreetype6-dev \
libtiff4-dev libavdevice-dev \
libavformat-dev libavutil-dev libavcodec-dev libjack-dev \
libswscale-dev libx264-dev libmp3lame-dev python3.2-dev \
libspnav-dev libtheora-dev libjack-dev libglew1.6-dev

关于python - 如何在标准 python 控制台中访问 BPY? BPY 是 Blender-python 的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10972637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com