Skip to content

Commit b730a4d

Browse files
committed
fixes
1 parent 82fa199 commit b730a4d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/compas/scene/scene.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ def node_repr(node):
7878

7979
@property
8080
def items(self):
81-
# type: () -> list
81+
# type: () -> list[compas.data.Data]
8282
return list(self.datastore.values())
8383

8484
@property
8585
def objects(self):
86-
# type: () -> list
86+
# type: () -> list[SceneObject]
8787
return list(self.objectstore.values())
8888

8989
@property
9090
def context_objects(self):
91-
# type: () -> list
91+
# type: () -> list[SceneObject]
9292
guids = []
9393
for obj in self.objects:
9494
guids += obj.guids
@@ -113,6 +113,11 @@ def add(self, item, parent=None, **kwargs):
113113
The scene object associated with the item.
114114
"""
115115

116+
if "context" in kwargs:
117+
if kwargs["context"] != self.context:
118+
raise Exception("Object context should be the same as scene context: {} != {}".format(kwargs["context"], self.context))
119+
del kwargs["context"] # otherwist the SceneObject receives "context" twice, which results in an error
120+
116121
# Create a corresponding new scene object
117122
sceneobject = SceneObjectFactory.create(item=item, context=self.context, scene=self, **kwargs)
118123

src/compas/scene/sceneobject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ def contrastcolor(self, color):
286286
self._contrastcolor = Color.coerce(color)
287287

288288
def add(self, item, **kwargs):
289-
"""Add a scene object to the scene.
289+
"""Add a child item to the scene object.
290290
291291
Parameters
292292
----------
293293
item : :class:`compas.data.Data`
294-
The item to add to the scene.
294+
The item to add.
295295
**kwargs : dict
296296
Additional keyword arguments to pass to the SceneObject constructor.
297297

0 commit comments

Comments
 (0)