Skip to content

Commit 1a4108d

Browse files
committed
always pull before merging main
2 parents aec1e88 + 7dce88d commit 1a4108d

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

AUTHORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
- Nik Eftekhar Olivo <<[email protected]>> [@nikeftekhar](https://github.com/nikeftekhar)
2828
- Beverly Lytle <<[email protected]>> [@beverlylytle](https://github.com/beverlylytle>)
2929
- Juney Lee <<[email protected]>> [@juney-lee](https://github.com/juney-lee)
30-
- Xingxin He <<[email protected]>> [@XingxinHE](https://github.com/XingxinHE)
30+
- Xingxin He <<[email protected]>> [@XingxinHE](https://github.com/XingxinHE)
31+
- Robin Godwyll <<[email protected]>> [@robin-gdwl](https://github.com/robin-gdwl)

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
89
## Unreleased
910

1011
### Added
1112

1213
* Added `RobotModel.remove_link`, `RobotModel.remove_joint`, `RobotModel.to_urdf_string`, and `RobotModel.ensure_geometry`.
14+
* Added Blender Python-example to the documentation section: Tutorials -> Robots
1315
* Added `compas_blender.unload_modules`.
1416

1517
### Changed
@@ -23,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2325
* Fixed bug regarding a repeated call to `RobotModel.add_joint`.
2426
* Fixed bug in `compas_blender.RobotModelArtist.update`.
2527
* Fixed bug in `compas.datastructures.mesh_slice_plane`.
28+
* Fixed bug where initialising a `compas_blender.artists.Robotmodelartist` would create a new collection for each mesh and then also not put the mesh iton the created collection.
29+
* Changed the initialisation of `compas_blender.artists.Robotmodelartist` to include a `collection`-parameter instead of a `layer`-parameter to be more consistent with Blender's nomenclature.
30+
* Used a utility function from `compas_blender.utilities` to create the collection if none exists instead of using a new call to a bpy-method.
2631

2732
### Removed
2833

docs/tutorial/robots.rst

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,29 @@ Visualizing Robots
148148
Before jumping into how to build a robot model, let's first see how to visualize
149149
one. This can be done with Blender, Rhino or Grasshopper using one of COMPAS's
150150
artists. The basic procedure is the same in
151-
any of the CAD software (aside from the import statement), so for simplicity we
152-
will demonstrate the use of :class:`compas_rhino.artists.RobotModelArtist` in Rhino.
151+
any of the CAD software (aside from the import statement). Below you can find an example code for both Rhino and Blender.
152+
153+
154+
.. raw:: html
155+
156+
<div class="card">
157+
<div class="card-header">
158+
<ul class="nav nav-tabs card-header-tabs">
159+
<li class="nav-item">
160+
<a class="nav-link active" data-toggle="tab" href="#visualise_robot_rhino">Rhino</a>
161+
</li>
162+
<li class="nav-item">
163+
<a class="nav-link" data-toggle="tab" href="#visualise_robot_blender">Blender</a>
164+
</li>
165+
</ul>
166+
</div>
167+
<div class="card-body">
168+
<div class="tab-content">
169+
170+
.. raw:: html
171+
172+
<div class="tab-pane active" id="visualise_robot_rhino">
173+
153174
Be sure to first install COMPAS for Rhino. While the following code is incomplete,
154175
it can be used as a scaffolding for code to be run in a Python script editor within Rhino.
155176

@@ -167,8 +188,42 @@ it can be used as a scaffolding for code to be run in a Python script editor wit
167188
artist.clear_layer()
168189
artist.draw_visual()
169190
191+
.. raw:: html
192+
193+
</div>
194+
<div class="tab-pane" id="visualise_robot_blender">
195+
196+
.. code-block:: python
197+
198+
import compas
199+
from compas.robots import RobotModel
200+
import compas_blender
201+
from compas_blender.artists import RobotModelArtist
202+
203+
compas_blender.clear() # Delete all objects in the Blender scene
204+
205+
model = RobotModel('Robby')
206+
207+
# Add some geometry to Robby here
208+
209+
# Load the robot geometry into the blender scene
210+
artist = RobotModelArtist(model, collection='COMPAS::Example Robot')
211+
212+
Note that the blender ``RobotModelArtist`` is not as developed as the one for Rhino.
213+
214+
.. raw:: html
215+
216+
</div>
217+
218+
.. raw:: html
219+
220+
</div>
221+
</div>
222+
</div>
223+
224+
170225

171-
See below for a complete example.
226+
See below for a complete example of how to programmatically create a Robotmodel.
172227

173228

174229
Building robots models

src/compas_blender/artists/robotmodelartist.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class RobotModelArtist(BaseRobotModelArtist):
1818
Robot model.
1919
"""
2020

21-
def __init__(self, model):
21+
def __init__(self, model, collection=None):
22+
self.collection = collection
2223
super(RobotModelArtist, self).__init__(model)
2324

2425
def transform(self, native_mesh, transformation):
@@ -36,8 +37,11 @@ def create_geoemetry(self, geometry, name=None, color=None):
3637
else:
3738
color = (1., 1., 1.)
3839

40+
if self.collection and self.collection not in bpy.data.collections.keys():
41+
compas_blender.utilities.create_collection(self.collection)
42+
3943
v, f = geometry.to_vertices_and_faces()
40-
native_mesh = compas_blender.draw_mesh(vertices=v, faces=f, name=name, color=color, centroid=False)
44+
native_mesh = compas_blender.draw_mesh(vertices=v, faces=f, name=name, color=color, centroid=False, collection=self.collection)
4145
native_mesh.hide_set(True)
4246
return native_mesh
4347

src/compas_blender/utilities/drawing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def _link_objects(objects, collection=None, layer=None):
4646
# if not layer:
4747
# layer = bpy.context.view_layer
4848
# layer_collection = layer.active_layer_collection.collection
49+
4950
for o in objects:
5051
for c in o.users_collection:
5152
c.objects.unlink(o)

0 commit comments

Comments
 (0)