Hi everyone,
I am currently facing this issue:
- Objective: I am trying to receive Speckle data as Base objects, in the ideal JSON form represented in the SpecklePy+Streamlit tutorial
-
Issue: Even if I use the same code in the above mentioned example usage of SpecklePy, there seems to be the issue that what I receive is a Collection, and not a Base Object.
Moreover, if I try to deserialize what I receive with the following code:
def get_stream_from_url(url):
return url.split("/streams/")[1].split("/")[0]
def get_referenced_objs_from_commits(commits, latest_only='N'):
if latest_only=='N':
refobjs = []
for commit in commits:
refobjs.append(commit.referencedObject)
else:
refobjs = [commits[0].referencedObject]
return refobjs
# provide any stream, branch, commit, object, or globals url
def speckle2json(url, last_only):
wrapper = StreamWrapper(url)
# get an authenticated SpeckleClient if you have a local account for the server
client = wrapper.get_client()
l = client.commit.list(get_stream_from_url(url))
onjsss = get_referenced_objs_from_commits(l)
# get an authenticated ServerTransport if you have a local account for the server
transport = wrapper.get_transport()
files = []
for onj in onjsss:
rec = operations.receive(onj, transport)
serializer = BaseObjectSerializer()
hash, obj_dict = serializer.traverse_base(rec)
hash, serialized = serializer.write_json(rec)
jsonfile = open(f"object_{onj}.json", "w")
jsonfile.write(serialized)
jsonfile.close()
files.append(f"object_{onj}.json")
return files
I get huge JSON files (>20 MB), encompassing multiple objects flooded with numeric arrays (that, I assume, represent the FacesValue).
- Example: If necessary, I can share the JSON file I get back from the above code
- Speckle link: Link to the URL I am using to download it: Speckle