Specklepy - cant receive commit from client?

Hi everyone!

About a year ago I wrote a python script that would grab objects from an existing stream/commit, my objective was to grab elements from a Revit model draw them into ETABS one by one.

Anyway, I’m revisiting my code now and I’m finding its no longer working, the problem is this line of code below.

image

The commit is always None:

image

Previously, I was able to use operations.receive from commit but now it no longer seems to work, this is the code that used to follow:

image

Has something changed in the past year or so that makes this no longer work?

Any help would be greatly appreciated, thanks!

1 Like

Hey @ZStructural

It is possibly a bit challenging to give a comprehensive answer based on a few lines of code, so appologies if the follow-up questions seem a bit straightforward:

  • There are no errors or warning messages, just an empty return?
  • Assuming client has been authenticated (authenticate_with_token)?
  • Has the stream_id or commit_id changed?

@Nikos has done some cool work in grabbing information from Revit recently, so any changes (of which I’m not aware) would be included in this code:

from specklepy.transports.server import ServerTransport
from specklepy.api import operations
from specklepy.api.client import SpeckleClient

client = SpeckleClient(host="https://latest.speckle.systems") # OR https://app.speckle.systems/
client.authenticate_with_token("SPECKLE_TOKEN") # Prviate token

new_stream_id = "STREAM_ID"
obj_id = "OBJ_ID"

transport = ServerTransport(client=client, stream_id=new_stream_id)
new_stream = client.stream.get(id=new_stream_id)
received_base = operations.receive(obj_id=obj_id, remote_transport=transport)
print(received_base)

This will receive your model as a collection.

Does this help? If not, please do share more of the code (removing any tokens / model ids etc.) with me so I can have a better look.

Cheers,
Björn :cool_spockle:

3 Likes

Hey bjoern,

Thanks for the response! Using your code above, I get the following error.

image

I’m a bit confused about obj_id, is this the commit ID? I’ve made sure that my model is public, still getting this error.

Hey again bjoern,

I think I found the problem, which ended up being rather obvious!

Initially, I was copying the stream and commit ID from the URL on the new web app. I understand these were renamed to ‘projects’ and ‘models’ some time ago. What I noticed, is that the commit ID on the new and old web apps are different. I tried my old code with the ID from the old web app and it worked.

Is this deliberate or is it something that should be fixed? Looks like it might cause confusion, especially for those with existing code.

Thanks!

Hey @ZStructural,

Ah yeah, apologies for not explaining that. Every object has an id, even the model itself has an id. If you open up a model, navigate to Scene Explorer on the left-hand side and activate dev mode, the model id will be at the upper most hierarchical level:

To your second point, if you’re using the new web app, would the host not be the https://latest.speckle.systems/ address instead of the https://app.speckle.systems ?

You are correct, we are a little bit in limbo regarding naming. In the web app we have renamed the structure to projects → models → versions, however, specklepy should still be referencing the old naming without any problems :slight_smile:

2 Likes

Thanks bjoern, that makes sense now. I just tried using operations.receive using the object ID from the new web app per your screenshot, and it works.

image

Is there a way to open the new web app by default? Currently I always get directed to the old app by default.

1 Like

Maybe important to note here, the “new web app” (under latest.speckle.systems) is our development server and is flagged as “transient” because we keep the server at the cutting edge of our development branch.

What do you mean by default: through the connectors or through the speckle.systems website? On the connectors side, you can select a default account through the Manager:

2 Likes