Unity Connector Question about speckle data

Hi all,

I’m wondering how I can access certain object data within the unity connector.

The data that I want to get is this Level component, and I can clearly see it within the stream objects.
But from within Unity, I’m not certain how I can access this.

I thought that it would be as a <string, object> pair in the SpeckleData.Data dictionary. I would have expected this to contain the properties that I’m trying to get, but when I debug, most of the time data is empty, or just contains the render material.

I tried to take a dive into the unity connector code, and I think the SpeckleData is created from this Base object. But I’ve got no further with that.

I’m using the latest unity connector for v2 speckle, I’m not sure if this is implemented yet, or if there is some bug, or perhaps I’m looking at the wrong things.

Any help with this would be greatly appreciated.

Hey again!

You are accessing the Speckle Data correctly, but there’s a bit of extra complexity here because of how Revit data is structured, lemme try to explain:

If you send a mesh from Rhino to Unity, any metadata on the mesh will appear in the SpeckleData dictionary, just as you would expect. This line in the converter is taking care of creating the dictionary and attaching it.

When you send elements from Revit it’s slightly more complex. Let’s say you send a Wall, it will be sent using this data structure. A dynamic property called displayMesh is attached containing its mesh representation, while the properties field contains all the metadata (equivalent of the SpeckleData in unity).
In Unity we haven’t written conversions for all the built elements supported by Speckle, there’s actually just one main conversion for meshes. So when the Wall is received, we traverse through all its properties until we find something that can be converted, in this case the displayMesh. Since the properties field is on the wall and not on the mesh it gets lots and it’s not attached to the GameObject.

One solution we could implement for this would be the following:

  • adding an IBuiltElem interface to all our builtelements
  • in the Unity converter, check if the Base object received is a IBuiltElem
  • if so, skip traversing it and just pick it’s displayMesh property and attach to it the properties of the main object

Here’s a temporary issue for it: Attach Revit properties on GameObjects · Issue #12 · specklesystems/speckle-unity · GitHub

I’ll let you know when we improve this, in the meantime, the only workaround would be for you to write a new conversion routine that attaches to the GameObejct the properties coming from its parent object and not from the mesh itself.

Hope it helps!

Thanks for the reply,
I have implemented a fairly bodgy workaround which is just to generate SpeckleData for all (non-native) base objects.

Not the most ideal solution, I now have quite a lot of GameObjects I’m never going to use, but atleast now I have the flexibility to use meta data coming from Revit.

Thanks for the support, not sure I would have been able to do it without your guidance.

1 Like

Ah, great :smiley:
We have planned a fix to this for the current sprint, will keep you posted!

Hey @Jedd , quick note to say that this is now fixed! Speckle data should be attached correctly on the received meshes whether they are coming from Rhino or Revit alike.
I’ve renamed a couple of functions as well, hopefully it doesn’t mess up your project too much!

1 Like