Skip to content

Commit

Permalink
Merge pull request #1057 from JeffreyWardman/master
Browse files Browse the repository at this point in the history
allow for dictionary input in Group and Assembly
  • Loading branch information
marcomusy authored Feb 20, 2024
2 parents fbcfde3 + 82483c7 commit 1da1879
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions vedo/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ class Group(vtki.vtkPropAssembly):

def __init__(self, objects=()):
"""Form groups of generic objects (not necessarily meshes)."""

super().__init__()

if isinstance(objects, dict):
for name in objects:
objects[name].name = name
objects = list(objects.values())

self.actor = self

self.name = "Group"
Expand Down Expand Up @@ -211,11 +215,17 @@ def __init__(self, *meshs):
filename = vedo.file_io.download(meshs[0], verbose=False)
data = np.load(filename, allow_pickle=True)
meshs = [vedo.file_io._from_numpy(dd) for dd in data]

if len(meshs) == 1:
# Name and load from dictionary
if len(meshs) == 1 and isinstance(meshs[0], dict):
meshs = meshs[0]
for name in meshs:
meshs[name].name = name
meshs = list(meshs.values())
else:
meshs = vedo.utils.flatten(meshs)
if len(meshs) == 1:
meshs = meshs[0]
else:
meshs = vedo.utils.flatten(meshs)

self.actor = self
self.actor.retrieve_object = weak_ref_to(self)
Expand Down

0 comments on commit 1da1879

Please sign in to comment.