Hello
I am trying to establish a workflow between grasshopper and CPython for transferring meshes. I have a problem receiving objects that are created and sent from the GH side in CPython. Here is how I am trying to receive the latest objects:
client = SpeckleClient(host="speckle.xyz", use_ssl=True)
account = get_default_account()
client.authenticate(token=account.token)
my_stream = client.stream.get("de0e6cf898")
transport = ServerTransport(client=client, stream_id=my_stream)
last_obj_id = client.commit.list(my_stream.id)[0].referencedObject
last_obj = operations.receive(obj_id=last_obj_id, remote_transport=transport)
you can find the commit that I am trying to retrieve here: Speckle
I am using specklepy-2.2.9 with python 3.8.5 on macOS.
I would appreciate your help.
2 Likes
AlanRynne
(Alan Rynne)
18 August 2021 07:20
2
Hi there @shervin_azadi !
I think you just have a minor error in your code that may be preventing it from executing correctly.
When creating the ServerTransport, the second input is the stream ID
, not the stream object. Try this out, it should work
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_default_account
from specklepy.api import operations
from specklepy.transports.server.server import ServerTransport
stream_id = "de0e6cf898"
client = SpeckleClient(host="speckle.xyz", use_ssl=True)
account = get_default_account()
client.authenticate(token=account.token)
transport = ServerTransport(client=client, stream_id=stream_id)
last_obj_id = client.commit.list(stream_id)[0].referencedObject
last_obj = operations.receive(obj_id=last_obj_id, remote_transport=transport)
print(str(last_obj_id))
Also, welcome to the Community! Feel free to Introduce yourself 🙆 to everyone here if you feel like it
3 Likes
Hi Alan
Thanks for the swift response. Indeed, you were right. After swaping the stream object with stream id the issue was resolved.
I will gladly introduce myself to the rest of the community.
Cheers,
3 Likes