Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* Added `RobotModel.remove_link`, `RobotModel.remove_joint`, `RobotModel.to_urdf_string`, and `RobotModel.ensure_geometry`.
* Added `compas_blender.unload_modules`.

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/compas_blender/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from .objects import * # noqa: F401 F403
from .collections import * # noqa: F401 F403
from .drawing import * # noqa: F401 F403
from .misc import * # noqa: F401 F403


__all__ = [name for name in dir() if not name.startswith('_')]
30 changes: 30 additions & 0 deletions src/compas_blender/utilities/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys


__all__ = [
'unload_modules',
]


def unload_modules(top_level_module_name):
"""Unloads all modules named starting with the specified string.

This function eases the development workflow when editing a library that is
used from Blender.

Parameters
----------
top_level_module_name : :obj:`str`
Name of the top-level module to unload.

Returns
-------
list
List of unloaded module names.
"""
modules = list(filter(lambda m: m.startswith(top_level_module_name), sys.modules))

for module in modules:
sys.modules.pop(module)

return modules