diff --git a/CHANGELOG.md b/CHANGELOG.md index 2683a27d26ba..ea29c29094b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Fixed bug in Blender mesh conversion. +* Changed Rhino plugin installer to check for and install required plugin packages. + ### Removed diff --git a/src/compas_blender/conversions/mesh.py b/src/compas_blender/conversions/mesh.py index 4a7cd50ede4b..cb0476c5c3cf 100644 --- a/src/compas_blender/conversions/mesh.py +++ b/src/compas_blender/conversions/mesh.py @@ -10,16 +10,40 @@ class BlenderMesh(BlenderGeometry): """Wrapper for Blender meshes. + Attributes + ---------- + object : :blender:`bpy.types.Object` + The Blender scene object. + geometry : :blender:`bpy.types.Mesh` + The mesh data block. + bmesh : :blender:`bpy.types.BMesh` + The mesh data structure. + location : :class:`~compas.geometry.Point` + The location of the object in the scene. + vertices : List[:class:`~compas.geometry.Point`] + The mesh vertex locations. + faces : List[List[:obj:`int`]] + The mesh face vertices. + Examples -------- .. code-block:: python - pass + import os + import compas + from compas_blender.conversions import BlenderMesh + + mesh = BlenderMesh.from_monkey().to_compas() + mesh = mesh.subdivide(k=2) + + path = os.path.join(os.path.expanduser(~), 'Desktop', 'monkey.json') + + compas.json_dump(mesh, path) + """ @property def object(self): - """:blender:`bpy.types.Object` - The Blender scene object.""" return self._object @object.setter @@ -30,7 +54,6 @@ def object(self, obj): @property def geometry(self): - """:blender:`bpy.types.Mesh` - The mesh data block.""" return self._geometry @geometry.setter @@ -40,23 +63,21 @@ def geometry(self, data): @property def bmesh(self): - """:blender:`bpy.types.BMesh` - The mesh data structure.""" return bmesh.from_edit_mesh(self.mesh) @property def location(self): - """:class:`~compas.geometry.Point` - The location of the object in the scene.""" - return Point(self.geometry.location) + if self.object: + return Point(self.object.location) + return Point(0, 0, 0) @property def vertices(self): - """List[:class:`~compas.geometry.Point`] - The mesh vertex locations.""" point = self.location return [point + list(vertex.co) for vertex in self.geometry.vertices] @property def faces(self): - """List[List[:obj:`int`]] - The mesh face vertices.""" return [list(face.vertices) for face in self.geometry.polygons] @classmethod @@ -75,6 +96,7 @@ def from_bmesh(cls, bm, name=None, free=True): Returns ------- :class:`~compas_blender.conversions.BlenderMesh` + """ data = bpy.data.meshes.new(name or 'Mesh') bm.to_mesh(data) @@ -96,6 +118,7 @@ def from_monkey(cls, name=None): Returns ------- :class:`~compas_blender.conversions.BlenderMesh` + """ bm = bmesh.new() bmesh.ops.create_monkey(bm) @@ -117,6 +140,7 @@ def to_compas(self, cls=None): Returns ------- :class:`~compas.datastructure.Mesh` + """ cls = cls or Mesh return cls.from_vertices_and_faces(self.vertices, self.faces) diff --git a/src/compas_rhino/install.py b/src/compas_rhino/install.py index 51f23ab1f535..3230cf6d1987 100644 --- a/src/compas_rhino/install.py +++ b/src/compas_rhino/install.py @@ -187,7 +187,7 @@ def install(version=None, packages=None, clean=False): # output the outcome of the installation process # perhaps we should more info here - print('Installing COMPAS packages to Rhino {0} scripts folder:'.format(version)) + print('\nInstalling COMPAS packages to Rhino {0} scripts folder:'.format(version)) print('{}\n'.format(scripts_path)) for package, status in results: diff --git a/src/compas_rhino/install_plugin.py b/src/compas_rhino/install_plugin.py index ee1178c6ca6e..6da159ee83e9 100644 --- a/src/compas_rhino/install_plugin.py +++ b/src/compas_rhino/install_plugin.py @@ -5,6 +5,7 @@ from compas._os import create_symlinks from compas._os import remove_symlinks +from .install import install as install_packages __all__ = ['install_plugin'] @@ -134,6 +135,11 @@ def install_plugin(plugin, version=None): source = plugin_dir destination = os.path.join(python_plugins_path, plugin_fullname) + # Stat the installation process + + if hasattr(__plugin__, 'packages'): + install_packages(version=version, packages=__plugin__.packages) + print('\nInstalling PlugIn {} to Rhino PythonPlugIns.'.format(plugin_name)) remove_symlinks([destination])