I am experimenting with the .NET Speckle SDK, receiving files, and then sending them back to the server.
I run the Speckle Server dockerized using the docker-compose files found in the Speckle Server repository.
I receive and send the objects to the server, but upon doing so, the objects are not visible on the server.
public class Point : Base
{
public double x { get; set; }
public double y { get; set; }
public double z { get; set; }
}
And here is the part of my code that uses the SDK.
var account = new Account();
account.token = "my-generated-token";
account.serverInfo = new ServerInfo
{
url = "http://speckle-server:3000/"
};
// The id of the stream to work with (we're assuming it already exists in your default account's server)
var streamId = "d3b6267877";
// The name of the branch we'll send data to.
var branchName = "main";
// Authenticate using the account
var client = new Client(account);
// Get the main branch with it's latest commit reference
var branch = client.BranchGet(streamId, branchName, 1).Result;
// Get the id of the object referenced in the commit
var hash = branch.commits.items[0].referencedObject;
// Create the server transport for the specified stream.
var transport = new ServerTransport(account, streamId);
// Receive the object
var receivedBase = Operations.Receive(hash, transport).Result;
//this works
//Point p1 = new Point();
//p1.x = 5;
//p1.y = 5;
//p1.z = 5;
//var speckleObject = new Base();
//speckleObject["@data"] = p1; // Attach your serialized geometry as the data of the Speckle object
//speckleObject["@type"] = "MyGeometryClass";
// Sending the object will return it's unique identifier.
var newHash = Operations.Send(receivedBase/*speckleObject*/, new List<ITransport> { transport }).Result;
var commitId = client.CommitCreate(
new CommitCreateInput
{
branchName = branchName,
objectId = newHash,
streamId = streamId,
message = "Automatic commit created by the c# webapplication app",
sourceApplication = "c# WebApplication1",
}).Result;
client.Dispose();