Skip to content

try data store again#1470

Closed
Licini wants to merge 1 commit into
mainfrom
datastore
Closed

try data store again#1470
Licini wants to merge 1 commit into
mainfrom
datastore

Conversation

@Licini

@Licini Licini commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Another attempt for data store only update. Please comments below...

@Licini Licini requested a review from tomvanmele June 2, 2025 15:22
Comment thread src/compas/scene/scene.py
items = {str(item.guid): item for item in data["items"]}

def add(node, parent, items):
scene = cls(data["name"], datastore=data["datastore"])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this version, we still allow direct serialization and deserialization of datastore attribute

Comment thread src/compas/scene/scene.py
Comment on lines +109 to +111
if isinstance(item, Group):
raise Exception("Use Scene.add_group to add a group to the scene.")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letting users to interact with a Group instance before properly attached to Scene is fragile, this is added to prevent that and ask user to use scene.add_group instead, so the links are property established.

Comment thread src/compas/scene/scene.py
Comment on lines +128 to +133
def add_group(self, name=None, parent=None, **kwargs):
# type: (str, SceneObject | TreeNode | None, dict) -> Group
parent = parent or self.root
group = Group(name=name, **kwargs)
super(Scene, self).add(group, parent=parent)
return group

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another reason we must have this function is that: Group class is not registered with an item and can not automatically reconstructed with correct extension class in a different context like Viewer. For example in Viewer we must overwrite this function to use compas_viewer.scene.Group instead of the original one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant