Skip to content

Commit 636f501

Browse files
authored
Merge pull request #1014 from compas-dev/workshop-fixes
Workshop fixes
2 parents 02c5a76 + d7e105b commit 636f501

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Fixed bug in Blender mesh conversion.
15+
* Changed Rhino plugin installer to check for and install required plugin packages.
16+
1417
### Removed
1518

1619

src/compas_blender/conversions/mesh.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,40 @@
1010
class BlenderMesh(BlenderGeometry):
1111
"""Wrapper for Blender meshes.
1212
13+
Attributes
14+
----------
15+
object : :blender:`bpy.types.Object`
16+
The Blender scene object.
17+
geometry : :blender:`bpy.types.Mesh`
18+
The mesh data block.
19+
bmesh : :blender:`bpy.types.BMesh`
20+
The mesh data structure.
21+
location : :class:`~compas.geometry.Point`
22+
The location of the object in the scene.
23+
vertices : List[:class:`~compas.geometry.Point`]
24+
The mesh vertex locations.
25+
faces : List[List[:obj:`int`]]
26+
The mesh face vertices.
27+
1328
Examples
1429
--------
1530
.. code-block:: python
1631
17-
pass
32+
import os
33+
import compas
34+
from compas_blender.conversions import BlenderMesh
35+
36+
mesh = BlenderMesh.from_monkey().to_compas()
37+
mesh = mesh.subdivide(k=2)
38+
39+
path = os.path.join(os.path.expanduser(~), 'Desktop', 'monkey.json')
40+
41+
compas.json_dump(mesh, path)
42+
1843
"""
1944

2045
@property
2146
def object(self):
22-
""":blender:`bpy.types.Object` - The Blender scene object."""
2347
return self._object
2448

2549
@object.setter
@@ -30,7 +54,6 @@ def object(self, obj):
3054

3155
@property
3256
def geometry(self):
33-
""":blender:`bpy.types.Mesh` - The mesh data block."""
3457
return self._geometry
3558

3659
@geometry.setter
@@ -40,23 +63,21 @@ def geometry(self, data):
4063

4164
@property
4265
def bmesh(self):
43-
""":blender:`bpy.types.BMesh` - The mesh data structure."""
4466
return bmesh.from_edit_mesh(self.mesh)
4567

4668
@property
4769
def location(self):
48-
""":class:`~compas.geometry.Point` - The location of the object in the scene."""
49-
return Point(self.geometry.location)
70+
if self.object:
71+
return Point(self.object.location)
72+
return Point(0, 0, 0)
5073

5174
@property
5275
def vertices(self):
53-
"""List[:class:`~compas.geometry.Point`] - The mesh vertex locations."""
5476
point = self.location
5577
return [point + list(vertex.co) for vertex in self.geometry.vertices]
5678

5779
@property
5880
def faces(self):
59-
"""List[List[:obj:`int`]] - The mesh face vertices."""
6081
return [list(face.vertices) for face in self.geometry.polygons]
6182

6283
@classmethod
@@ -75,6 +96,7 @@ def from_bmesh(cls, bm, name=None, free=True):
7596
Returns
7697
-------
7798
:class:`~compas_blender.conversions.BlenderMesh`
99+
78100
"""
79101
data = bpy.data.meshes.new(name or 'Mesh')
80102
bm.to_mesh(data)
@@ -96,6 +118,7 @@ def from_monkey(cls, name=None):
96118
Returns
97119
-------
98120
:class:`~compas_blender.conversions.BlenderMesh`
121+
99122
"""
100123
bm = bmesh.new()
101124
bmesh.ops.create_monkey(bm)
@@ -117,6 +140,7 @@ def to_compas(self, cls=None):
117140
Returns
118141
-------
119142
:class:`~compas.datastructure.Mesh`
143+
120144
"""
121145
cls = cls or Mesh
122146
return cls.from_vertices_and_faces(self.vertices, self.faces)

src/compas_rhino/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def install(version=None, packages=None, clean=False):
187187

188188
# output the outcome of the installation process
189189
# perhaps we should more info here
190-
print('Installing COMPAS packages to Rhino {0} scripts folder:'.format(version))
190+
print('\nInstalling COMPAS packages to Rhino {0} scripts folder:'.format(version))
191191
print('{}\n'.format(scripts_path))
192192

193193
for package, status in results:

src/compas_rhino/install_plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from compas._os import create_symlinks
77
from compas._os import remove_symlinks
8+
from .install import install as install_packages
89

910

1011
__all__ = ['install_plugin']
@@ -134,6 +135,11 @@ def install_plugin(plugin, version=None):
134135
source = plugin_dir
135136
destination = os.path.join(python_plugins_path, plugin_fullname)
136137

138+
# Stat the installation process
139+
140+
if hasattr(__plugin__, 'packages'):
141+
install_packages(version=version, packages=__plugin__.packages)
142+
137143
print('\nInstalling PlugIn {} to Rhino PythonPlugIns.'.format(plugin_name))
138144

139145
remove_symlinks([destination])

0 commit comments

Comments
 (0)