Skip to content

work with datastore#214

Closed
Licini wants to merge 1 commit into
mainfrom
update/datastore
Closed

work with datastore#214
Licini wants to merge 1 commit into
mainfrom
update/datastore

Conversation

@Licini

@Licini Licini commented Jun 2, 2025

Copy link
Copy Markdown
Collaborator

Trying to work with this PR: compas-dev/compas#1470 , and enable the scene switching like below (which works, but we need to test more complicated cases):

from compas_viewer.viewer import Viewer
from compas.scene import Scene
from compas.geometry import Box, Translation

scene = Scene()
box = Box()
scene.add(box, color=(255, 0, 0), name="Box1")
group = scene.add_group(name="My Group")
obj2 = scene.add(box, color=(0, 0, 255), name="Box2", parent=group)
obj2.transformation = Translation().from_vector([2, 0, 0])


jsonstring = scene.to_jsonstring(pretty=True)
print(jsonstring)

scene_loaded = Scene.from_jsonstring(jsonstring)

viewer = Viewer()
viewer.scene = scene_loaded

viewer.show()

There is one compromise I had to make, we have to give up ability of set u, v parameters at object level.
The reason it that they require access to underlying item , which now has to go through self.scene.datastore[GUID]. However self.scene is not available until __init__ is finished. I cannot think of a quick and clean way yet, other than remove them all together... let me know if you have better ideas

@Licini Licini requested a review from tomvanmele June 2, 2025 15:44
@Licini Licini closed this Jun 3, 2025
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