Skip to content

Commit

Permalink
Merge pull request #7 from ami-iit/upgrade-blender-4
Browse files Browse the repository at this point in the history
Upgrade to blender 4
  • Loading branch information
Giulero authored Jul 24, 2024
2 parents 33c070a + e837838 commit 85dee20
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@

**Import your robot in Blender and create a nice render of it!**

https://github.com/ami-iit/blend-my-bot/assets/29798643/c224cd56-1d90-42dd-aec5-960a13690ce7
<https://github.com/ami-iit/blend-my-bot/assets/29798643/c224cd56-1d90-42dd-aec5-960a13690ce7>

</div>

## 🐍 Requirements

- [`python3`](<https://wiki.python.org/moin/BeginnersGuide>)
- [`Blender 3.6`](<https://www.blender.org/download/lts/3-6/>)
- [`Blender 4`](<https://www.blender.org/download/lts/3-6/>)
- [`iDynTree`](<https://github.com/robotology/idyntree>)
- [`numpy`](<https://numpy.org/>)
- [`bpy 3.6`](<https://pypi.org/project/bpy/>)
- [`bpy 4`](<https://pypi.org/project/bpy/>)

Note: This library has been tested with the `appimage` version of Blender 3.6. You should use a Python version that matches the one supported by the Blender version.
> [!NOTE]
> You should use a Python version that matches the one supported by the Blender version.
> For example, Blender 4 supports Python 3.10
Note 2: This library does not define the rig of the robot. For this, you can use a library such as [`blender-robotics-utils`](https://github.com/robotology/blender-robotics-utils).
> [!NOTE]
> This library does not define the rig of the robot. For this, you can use a library such as [`blender-robotics-utils`](https://github.com/robotology/blender-robotics-utils).
## 💾 Installation

Expand Down Expand Up @@ -114,6 +117,8 @@ Having the meshes in an `obj` format, instead, will give a nicer and more colorf

## 🦿 Troubleshooting

#### FileNotFoundError when running the script

If you install a new package in the conda environment but it is not working as you expect when you run the script, try to activate it in a terminal **before** and then open `Visual Studio Code` from the terminal:

```bash
Expand All @@ -129,6 +134,10 @@ FileNotFoundError: resolve-robotics-uri-py: No file corresponding to uri "packag

This is due to the fact that environmental variables are not sourced. Activating the conda environment before opening `vscode` solves this issue!

#### Crush when running the script

If Blender crashes when running the script from `Visual Studio Code`, try to run the script from the `Scripting` tab of Blender.

## 🦸‍♂️ Contributing

`blend-my-bot` is an open-source project. Contributions are very welcome!
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python_requires = >=3.10
install_requires =
idyntree
numpy
bpy==3.6
bpy

[options.packages.find]
where = src
5 changes: 3 additions & 2 deletions src/blend_my_bot/model_importer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dataclasses import dataclass
from typing import List

import bpy
import idyntree.bindings as idyntree
import numpy as np

from blend_my_bot import Link, BlenderModel
from blend_my_bot import BlenderModel, Link


@dataclass
Expand Down Expand Up @@ -99,7 +100,7 @@ def import_links(
mesh = bpy.data.objects[mesh_name]
elif mesh_path.endswith(".obj"):
print(f"Importing {mesh_path}")
bpy.ops.import_scene.obj(filepath=mesh_path)
bpy.ops.wm.obj_import(filepath=mesh_path)
mesh = bpy.context.selected_objects[0]
elif mesh_path.endswith(".stl"):
print(f"Importing {mesh_path}")
Expand Down

0 comments on commit 85dee20

Please sign in to comment.