From faeb67e0f13c0999e2293ff1851662549bea9e14 Mon Sep 17 00:00:00 2001 From: "Umut E. S." Date: Thu, 25 Jul 2024 16:21:04 +0300 Subject: [PATCH] Update assembly.py to get the vedo objects from Group easily, objects property added, and related changes applied --- vedo/assembly.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vedo/assembly.py b/vedo/assembly.py index 2f944ef1..832578f2 100644 --- a/vedo/assembly.py +++ b/vedo/assembly.py @@ -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 @@ -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): @@ -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": @@ -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):