Dear Speckle founders, employees, and community,
I’m Håkon and I am currently prototyping a Revit<->Spacemaker synchronization plugin on behalf of Spacemaker/Autodesk. Rather than reinventing the wheel, we are trying to use some of the lower level components of your libraries to get a head start with data modeling and serialization. As a bonus, you have solved many of the cross-compiling issues with different Revit versions.
We are truly impressed about what we’ve seen so far!
Our idea is to do something as the following:
var commitObject = new Base();
foreach (var o in speckleBases)
{
// Detachable property, yes please !!
commitObject["@" + o.GetId()] = o;
}
var (s, t) = Operations.GetSerializerInstance();
s.WriteTransports = new List<ITransport>() { new MemoryTransport() };
var obj = JsonConvert.SerializeObject(commitObject, t);
Logger.Info(obj);
However, the result of this doesn’t include much data, only one reference per selected object:
{
"@6c737a551f714a07cd828025424d7fd7": {
"speckle_type": "reference",
"referencedId": "4d6f6c3f9163ccbb8e47d8003e2bd425"
},
"@c14e446aff8e3a4c5d3b737521ef8664": {
"speckle_type": "reference",
"referencedId": "3358420a91a48335122a9fec243a6d6c"
},
"totalChildrenCount": 0,
"speckle_type": "Base",
"__closure": {
"a61250e40666ef7af5cf0367b4bd546a": 3,
"37d61eda7e2cfff131f3f74d71ab08d0": 3,
"be277d7552821f8ca9f24809837b6541": 2,
"4d6f6c3f9163ccbb8e47d8003e2bd425": 1,
"3644f78bc4ef1db14d5080951da66c36": 3,
"07a6171f07039b014b792d195ad45c99": 3,
"018a54b4d8e91c681d5bb1fac8e33544": 2,
"3358420a91a48335122a9fec243a6d6c": 1
},
"id": "d4a43160b480f6d7535b6195b0ebf9fe"
}
If we exclude the @
for those references, all data is included, but none of the elements in the tree are detached. We are looking for the meshes to turn them into glTF and view them in a web viewer, but we would have to recursively search for them.
What we have been looking for is a way to serialize the selection in the way that all detachable objects are included at root level, just like your object/
API. This way we can scan the list for types we recognize and display them, and ignore the rest.
Can anyone help me point out where our approach is wrong?
- Should we not make the root items detachable and recursively search for what we want in the tree?
- Is there a way to include the data that the IDs in the
__closure
is pointing to? - Should we start thinking about our problem differently?
(4. What is the best way to construct a commitObject? The GetId() serializes the object)
Thank you again!
Håkon