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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
40 changes: 32 additions & 8 deletions src/compas_blender/conversions/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -96,6 +118,7 @@ def from_monkey(cls, name=None):
Returns
-------
:class:`~compas_blender.conversions.BlenderMesh`

"""
bm = bmesh.new()
bmesh.ops.create_monkey(bm)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/compas_rhino/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions src/compas_rhino/install_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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])
Expand Down