Skip to content

Commit

Permalink
Update assembly.py
Browse files Browse the repository at this point in the history
to get the vedo objects from Group easily, objects property added, and related changes applied
  • Loading branch information
smoothumut authored Jul 25, 2024
1 parent 95a646e commit faeb67e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vedo/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ def __init__(self, objects=()):
"""Form groups of generic objects (not necessarily meshes)."""
super().__init__()

self.objects = []

if isinstance(objects, dict):
for name in objects:
objects[name].name = name
objects = list(objects.values())
elif vedo.utils.is_sequence(objects):
self.objects = objects


self.actor = self

Expand Down Expand Up @@ -139,6 +144,7 @@ def __iadd__(self, obj):
self.AddPart(a)
except TypeError:
self.AddPart(a.actor)
self.objcects.append(a)
return self

def _unpack(self):
Expand Down Expand Up @@ -166,6 +172,7 @@ def clear(self) -> "Group":
"""Remove all parts"""
for a in self._unpack():
self.RemovePart(a)
self.objects = []
return self

def on(self) -> "Group":
Expand Down Expand Up @@ -193,6 +200,10 @@ def print(self) -> "Group":
print(self)
return self

def objects(self) -> List["vedo.Mesh"]:
"""Return the list of objects in the group."""
return self.objects


#################################################
class Assembly(CommonVisual, Actor3DHelper, vtki.vtkAssembly):
Expand Down

0 comments on commit faeb67e

Please sign in to comment.