Skip to content

Commit 5e77fb0

Browse files
committed
update group APIs
1 parent ce2bb58 commit 5e77fb0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added `compas.scene.Scene.add_group()` for adding group.
13+
* Added `compas.scene.Group.add_from_list()` for adding a list of items to a group.
14+
1215
### Changed
1316

1417
* Fixed error in `circle_to_compas` from Rhino.
1518
* Fixed Rhino to Rhino brep serialization.
19+
* Upated `compas.scene.Group.add()` to pass on group kwargs as default for child items.
1620

1721
### Removed
1822

src/compas/scene/group.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class Group(SceneObject):
1111
----------
1212
name : str, optional
1313
The name of the group.
14+
**kwargs : dict, optional
15+
Additional keyword arguments to pass on to the child sceneobjects as default values.
16+
17+
Attributes
18+
----------
19+
kwargs : dict
20+
The keyword arguments to pass on to the child sceneobjects as default values.
1421
1522
Examples
1623
--------
@@ -36,7 +43,7 @@ def __new__(cls, *args, **kwargs):
3643

3744
def __init__(self, name, **kwargs):
3845
super(Group, self).__init__(name=name, **kwargs)
39-
self.group_kwargs = kwargs
46+
self.kwargs = kwargs
4047

4148
@property
4249
def __data__(self):
@@ -68,7 +75,7 @@ def add(self, item, **kwargs):
6875
ValueError
6976
If the scene object does not have an associated scene node.
7077
"""
71-
group_kwargs = self.group_kwargs.copy()
78+
group_kwargs = self.kwargs.copy()
7279
group_kwargs.update(kwargs)
7380
kwargs = group_kwargs
7481
return super(Group, self).add(item, **kwargs)

src/compas/scene/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def add(self, item, parent=None, **kwargs):
119119
del kwargs["context"] # otherwist the SceneObject receives "context" twice, which results in an error
120120
if isinstance(parent, Group):
121121
# Use the kwargs of the parent group as default values for the child sceneobject
122-
group_kwargs = parent.group_kwargs.copy()
122+
group_kwargs = parent.kwargs.copy()
123123
group_kwargs.update(kwargs)
124124
kwargs = group_kwargs
125125
sceneobject = SceneObject(item=item, context=self.context, **kwargs) # type: ignore

0 commit comments

Comments
 (0)