Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty scene serialisation #1404

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed import errors in `compas_rhino.conduits` for Rhino 8.
* Fixed doctest failures.
* Fixed bug in serialization when `compas.datastructures.attributes.AttributeView` is used.
* Fixed bug in the serialisation of empty scenes.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/compas/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __from_data__(cls, data):
items = {str(item.guid): item for item in data["items"]}

def add(node, parent, items):
for child_node in node["children"]:
for child_node in node.get("children", []):
guid = child_node["item"]
settings = child_node["settings"]
sceneobject = parent.add(items[guid], **settings)
Expand Down
6 changes: 6 additions & 0 deletions tests/compas/scene/test_scene_serialisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ def test_scene_serialisation(items, mocker):

scene2 = Scene.from_jsonstring(scene1.to_jsonstring())
assert assert_is_data_equal(scene1, scene2)

def test_scene_serialisation_empty():
scene = Scene()
scene = compas.json_loads(compas.json_dumps(scene))

assert isinstance(scene, Scene)
Loading