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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Changed new artist registration to check if subclass.
* Fixed `RobotModelArtist` for blender: missing abstract method impl and handle init order.

### Removed

Expand Down
5 changes: 2 additions & 3 deletions src/compas_blender/artists/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ class BlenderArtist(Artist):
def __init__(self,
collection: Optional[Union[str, bpy.types.Collection]] = None,
**kwargs: Any):

super().__init__(**kwargs)

# Initialize collection before even calling super because other classes depend on that
self._collection = None
self.collection = collection
super().__init__(**kwargs)

@property
def collection(self) -> bpy.types.Collection:
Expand Down
12 changes: 10 additions & 2 deletions src/compas_blender/artists/robotmodelartist.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,28 @@ def create_geometry(self,
def redraw(self, timeout: float = 0.0) -> None:
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1, time_limit=timeout)

def clear(self) -> None:
compas_blender.delete_objects(self.collection.objects)
def _ensure_geometry(self):
if len(self.collection.objects) == 0:
self.create()

def draw(self) -> None:
self._ensure_geometry()
self.draw_visual()

def draw_visual(self) -> None:
self._ensure_geometry()
visuals = super(RobotModelArtist, self).draw_visual()
for visual in visuals:
visual.hide_set(False)

def draw_collision(self) -> None:
self._ensure_geometry()
collisions = super(RobotModelArtist, self).draw_collision()
for collision in collisions:
collision.hide_set(False)

def draw_attached_meshes(self) -> None:
self._ensure_geometry()
meshes = super(RobotModelArtist, self).draw_attached_meshes()
for mesh in meshes:
mesh.hide_set(False)