I try to use Speckle.Autocad.API and kit converter to parse Autodesk DBObject and upload to Speckle. ConvertToSpeckle seems retrieve DBObject. However, its upload seems unable to display.
May I ask “no display value” is because loaded converter failed to convert DBObject or ConvertToSpeckle filed to convert? Thanks. The following is my code.
var kit = KitManager.GetDefaultKit();
var converter = kit.LoadConverter(“AutoCAD2022”);
IList blist = new List();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable blckTbl = tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = tr.GetObject(blckTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId objId in btr)
{
DBObject obj = tr.GetObject(objId, OpenMode.ForWrite) as DBObject;
try
{
blist.Add(converter.ConvertToSpeckle(obj));
}
catch{ }
}
}
try
{
var commitObject = new Base();
commitObject[“@all”] = blist;
string url_ = “https://speckle.xyz/”;
Account account = new Account();
account.token = token;
account.serverInfo = new ServerInfo
{
url = url_
};
var transports = new List<Speckle.Core.Transports.ITransport>() { new ServerTransport(account, streamid) };
Task.Run(async () => {
var objectId = await Operations.Send(
@object: commitObject,
transports: transports,
useDefaultCache: true
).ConfigureAwait(true);
var actualCommit = new CommitCreateInput()
{
streamId = streamid,
objectId = objectId,
branchName = "main",
message = "IFC",
sourceApplication = "Speckle API",
};
var client = new Client(account);
//client.CommitUpdate
var response = await client.CommitCreate(actualCommit);
});
}
catch(System.Exception ex) { MessageBox.Show(ex.ToString()); }
All regards,
Albert