Skip to content

Commit 10f6633

Browse files
committed
Fix empty scene serialisation
1 parent 166ac9d commit 10f6633

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
* Fixed import errors in `compas_rhino.conduits` for Rhino 8.
2020
* Fixed doctest failures.
2121
* Fixed bug in serialization when `compas.datastructures.attributes.AttributeView` is used.
22+
* Fixed bug in the serialisation of empty scenes.
2223

2324
### Removed
2425

src/compas/scene/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __from_data__(cls, data):
5656
items = {str(item.guid): item for item in data["items"]}
5757

5858
def add(node, parent, items):
59-
for child_node in node["children"]:
59+
for child_node in node.get("children", []):
6060
guid = child_node["item"]
6161
settings = child_node["settings"]
6262
sceneobject = parent.add(items[guid], **settings)

tests/compas/scene/test_scene_serialisation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,9 @@ def test_scene_serialisation(items, mocker):
115115

116116
scene2 = Scene.from_jsonstring(scene1.to_jsonstring())
117117
assert assert_is_data_equal(scene1, scene2)
118+
119+
def test_scene_serialisation_empty():
120+
scene = Scene()
121+
scene = compas.json_loads(compas.json_dumps(scene))
122+
123+
assert isinstance(scene, Scene)

0 commit comments

Comments
 (0)