Skip to content

Commit

Permalink
always pull before merging main
Browse files Browse the repository at this point in the history
  • Loading branch information
beverlylytle committed Feb 10, 2021
2 parents aec1e88 + 7dce88d commit 1a4108d
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
3 changes: 2 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
- Nik Eftekhar Olivo <<[email protected]>> [@nikeftekhar](https://github.com/nikeftekhar)
- Beverly Lytle <<[email protected]>> [@beverlylytle](https://github.com/beverlylytle>)
- Juney Lee <<[email protected]>> [@juney-lee](https://github.com/juney-lee)
- Xingxin He <<[email protected]>> [@XingxinHE](https://github.com/XingxinHE)
- Xingxin He <<[email protected]>> [@XingxinHE](https://github.com/XingxinHE)
- Robin Godwyll <<[email protected]>> [@robin-gdwl](https://github.com/robin-gdwl)
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## Unreleased

### Added

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

### Changed
Expand All @@ -23,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed bug regarding a repeated call to `RobotModel.add_joint`.
* Fixed bug in `compas_blender.RobotModelArtist.update`.
* Fixed bug in `compas.datastructures.mesh_slice_plane`.
* 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.
* 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.
* 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.

### Removed

Expand Down
61 changes: 58 additions & 3 deletions docs/tutorial/robots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,29 @@ Visualizing Robots
Before jumping into how to build a robot model, let's first see how to visualize
one. This can be done with Blender, Rhino or Grasshopper using one of COMPAS's
artists. The basic procedure is the same in
any of the CAD software (aside from the import statement), so for simplicity we
will demonstrate the use of :class:`compas_rhino.artists.RobotModelArtist` in Rhino.
any of the CAD software (aside from the import statement). Below you can find an example code for both Rhino and Blender.


.. raw:: html

<div class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#visualise_robot_rhino">Rhino</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#visualise_robot_blender">Blender</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content">

.. raw:: html

<div class="tab-pane active" id="visualise_robot_rhino">

Be sure to first install COMPAS for Rhino. While the following code is incomplete,
it can be used as a scaffolding for code to be run in a Python script editor within Rhino.

Expand All @@ -167,8 +188,42 @@ it can be used as a scaffolding for code to be run in a Python script editor wit
artist.clear_layer()
artist.draw_visual()
.. raw:: html

</div>
<div class="tab-pane" id="visualise_robot_blender">

.. code-block:: python
import compas
from compas.robots import RobotModel
import compas_blender
from compas_blender.artists import RobotModelArtist
compas_blender.clear() # Delete all objects in the Blender scene
model = RobotModel('Robby')
# Add some geometry to Robby here
# Load the robot geometry into the blender scene
artist = RobotModelArtist(model, collection='COMPAS::Example Robot')
Note that the blender ``RobotModelArtist`` is not as developed as the one for Rhino.

.. raw:: html

</div>

.. raw:: html

</div>
</div>
</div>



See below for a complete example.
See below for a complete example of how to programmatically create a Robotmodel.


Building robots models
Expand Down
8 changes: 6 additions & 2 deletions src/compas_blender/artists/robotmodelartist.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class RobotModelArtist(BaseRobotModelArtist):
Robot model.
"""

def __init__(self, model):
def __init__(self, model, collection=None):
self.collection = collection
super(RobotModelArtist, self).__init__(model)

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

if self.collection and self.collection not in bpy.data.collections.keys():
compas_blender.utilities.create_collection(self.collection)

v, f = geometry.to_vertices_and_faces()
native_mesh = compas_blender.draw_mesh(vertices=v, faces=f, name=name, color=color, centroid=False)
native_mesh = compas_blender.draw_mesh(vertices=v, faces=f, name=name, color=color, centroid=False, collection=self.collection)
native_mesh.hide_set(True)
return native_mesh

Expand Down
1 change: 1 addition & 0 deletions src/compas_blender/utilities/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _link_objects(objects, collection=None, layer=None):
# if not layer:
# layer = bpy.context.view_layer
# layer_collection = layer.active_layer_collection.collection

for o in objects:
for c in o.users_collection:
c.objects.unlink(o)
Expand Down

0 comments on commit 1a4108d

Please sign in to comment.