Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/blenderprochelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Run BlenderProcHelper
run: python /home/$USER/workspace/BlenderProcHelper/github_action.py
- name: Archive logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: logs
path: artifacts
path: artifacts
6 changes: 3 additions & 3 deletions blenderproc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
if is_using_external_bpy_module():
try:
import bpy
if bpy.app.version[0] != 4 and bpy.app.version[1] != 2:
raise RuntimeError("\n###############\nUSE_EXTERNAL_BPY_MODULE is set, but bpy module is not from Blender 4.2.\n\tpip install bpy==4.2.0\n###############\n")
if bpy.app.version[0] != 4 and bpy.app.version[1] != 4:
raise RuntimeError("\n###############\nUSE_EXTERNAL_BPY_MODULE is set, but bpy module is not from Blender 4.4.\n\tpip install bpy==4.4.0\n###############\n")

print(f"BlenderProc is using external 'bpy' ({bpy.app.version_string}) module found in the environment.")
# If we successfully imported bpy of correct version, we can signal that we are in the internal blender python environment
os.environ.setdefault("INSIDE_OF_THE_INTERNAL_BLENDER_PYTHON_ENVIRONMENT", "1")
except ImportError:
raise RuntimeError("\n###############\nUSE_EXTERNAL_BPY_MODULE is set, but bpy module could not be imported. Make sure bpy module is present in your python environment.\n\tpip install bpy==4.2.0\n###############\n")
raise RuntimeError("\n###############\nUSE_EXTERNAL_BPY_MODULE is set, but bpy module could not be imported. Make sure bpy module is present in your python environment.\n\tpip install bpy==4.4.0\n###############\n")


# check the python version, only python 3.X is allowed:
Expand Down
7 changes: 4 additions & 3 deletions blenderproc/python/loader/BlendLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ def load_blend(path: str, obj_types: Optional[Union[List[str], str]] = None, nam
# Find the maximum frame number of its key frames
max_keyframe = -1
if obj.animation_data is not None:
fcurves = obj.animation_data.action.fcurves
for curve in fcurves:
strip = obj.animation_data.action.layers[0].strips[0]
channelbag = strip.channelbag(obj.animation_data.action_slot, ensure=True)
for curve in channelbag.fcurves:
keyframe_points = curve.keyframe_points
for keyframe in keyframe_points:
max_keyframe = max(max_keyframe, keyframe.co[0])

# Set frame_end to the next free keyframe
bpy.context.scene.frame_end = max_keyframe + 1
bpy.context.scene.frame_end = int(max_keyframe + 1)
else:
# Remove object again if its type is not desired
bpy.data.objects.remove(obj, do_unlink=True)
Expand Down
6 changes: 3 additions & 3 deletions blenderproc/python/utility/InstallUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def make_sure_blender_is_installed(custom_blender_path: Optional[str], blender_i
blender_install_path = "blender"

# Determine configured version
# right now only support blender-4.2.1
major_version = "4.2"
minor_version = "1"
# right now only support blender-4.4.3
major_version = "4.4"
minor_version = "3"
blender_version = f"blender-{major_version}.{minor_version}"
if platform in ["linux", "linux2"]:
blender_version += "-linux-x64"
Expand Down
2 changes: 1 addition & 1 deletion blenderproc/python/utility/Utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def reset_keyframes() -> None:
""" Removes registered keyframes from all objects and resets frame_start and frame_end """
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = 0
for a in bpy.data.actions:
for a in list(bpy.data.actions):
bpy.data.actions.remove(a)


Expand Down
10 changes: 5 additions & 5 deletions docs/tutorials/bpy_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BlenderProc supports using `bpy` module installed from pip. This behavior is con
## Setup

1. Set `USE_EXTERNAL_BPY_MODULE=1` in your environment
2. `pip install bpy==4.2.0`
2. `pip install bpy==4.4.0`
3. Install [required packages](#required-dependencies)
4. After `import blenderproc` call `blenderproc.init()`
5. Run your script using `python my_script.py` or `blenderproc run my_script.py`
Expand All @@ -21,7 +21,7 @@ BlenderProc supports using `bpy` module installed from pip. This behavior is con
Following dependencies have to be installed in your environment to allow using BlenderProc with Python `bpy` module.

```
pip install wheel bpy==4.2.0 pyyaml==6.0.1 imageio==2.34.1 gitpython==3.1.43 scikit-image==0.23.2 pypng==0.20220715.0 scipy==1.13.1 matplotlib==3.9.0 pytz==2024.1 h5py==3.11.0 Pillow==10.3.0 opencv-contrib-python==4.10.* scikit-learn==1.5.0 python-dateutil==2.9.0.post0 rich==13.7.1 trimesh==4.4.0 pyrender==0.1.45 PyQT5
pip install wheel bpy==4.4.0 pyyaml==6.0.1 imageio==2.34.1 gitpython==3.1.43 scikit-image==0.23.2 pypng==0.20220715.0 scipy==1.13.1 matplotlib==3.9.0 pytz==2024.1 h5py==3.11.0 Pillow==10.3.0 opencv-contrib-python==4.10.* scikit-learn==1.5.0 python-dateutil==2.9.0.post0 rich==13.7.1 trimesh==4.4.0 pyrender==0.1.45 PyQT5
```

This is because BlenderProc does not require these dependencies directly, but the Blender it uses does. When using `bpy` package there is no Blender being installed and these dependencies become dependencies of the BlenderProc.
Expand All @@ -31,11 +31,11 @@ This is because BlenderProc does not require these dependencies directly, but th
### Python version mismatch

```
pip install bpy==4.2.0
pip install bpy==4.4.0
Defaulting to user installation because normal site-packages is not writeable
ERROR: Ignored the following versions that require a different python version: 2.82.1 Requires-Python >=3.7, <3.8
ERROR: Could not find a version that satisfies the requirement bpy==4.2.0 (from versions: none)
ERROR: No matching distribution found for bpy==4.2.0
ERROR: Could not find a version that satisfies the requirement bpy==4.4.0 (from versions: none)
ERROR: No matching distribution found for bpy==4.4.0
```

Using BlenderProc with `bpy` module from pip strictly requires Python3.11, see [Limitations](#limitations). Suggested workflow is to work with virtual environment using Python3.11.
Expand Down
Binary file added examples/resources/keyframed_camera.blend
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/testLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,17 @@ def perform_material_checks(used_material: bproc.types.Material, used_path: Path
texture = bpy.data.images.load(str(texture_path), check_existing=True)
material = bproc.material.create_material_from_texture(texture, material_name="new_mat")
perform_material_checks(material, texture_path)

def test_load_camera(self):
bproc.clean_up(True)
resource_folder = os.path.join(os.path.dirname(__file__), "..", "examples", "resources")
cameras = bproc.loader.load_blend(
os.path.join(resource_folder, "keyframed_camera.blend"),
data_blocks=["objects"],
name_regrex="Camera",
obj_types=["CAMERA"]
)

self.assertEqual(len(cameras), 1)
self.assertEqual(bpy.context.scene.frame_end, 101)
self.assertEqual(bpy.context.scene.camera, cameras[0].blender_obj)