How to send from Unity - Want to see what is in SpeckleProperties

Greetings. I have been using Speckle in connection to Revit for BIM implementation. So far it has been great for receiving models from Revit into Unity.

Now I am interested in sending it out of Unity. So how do I actually do this? I checked the docs section here: #Sending but I am not very experienced in programming so I did not understand much.

Reading the #Metadata section of the docs it says the model information is stored in the SpeckleProperties script, which is indeed added to each imported game object in Unity. But how do I see what is inside of it for each game object?

My reason for looking into this is: When you export a Revit model for example as IFC schema, each model entity gets a GUID (Global Unique Identifier) which can be used across different applications to make a reference to that exact same model entity.

I want to better understand if this GUID is somehow imported and preserved when receiving the model in Unity, and also if it is preserved when sending the model out of Unity. Thanks!

Hi @FilipeFinco,

Our current version of the connector doesn’t provide a convenient editor script for sending like we do for receiving. So to send geometry, you will need to write some code that uses the Sender class. This should offer you the functionality you need. You only need to specify the stream id, and a list of GameObjects to send.
The other properties are optional, and used if you want error handling/to be notified when the send operation is complete.

For a usage example, you can download our sample “Speckle Playground” project by cloning/downloading the unity repo. Checkout the InteractionLogic class.

This process may not be super straightforward, especially if you are new to unity, so please let me know if you are having any issues.


SpeckleProperties are a component that are attached to every GameObject created.
This should contain all the bim/custom properties you see when inspecting objects in the Speckle viewer.

Currently, the only way to access these properties, is from code.

SpeckleProperties props = myGameObject.GetComponent<SpeckleProperties>();

// props.Data is a IDictionary<string, object>

// you can check for a property like this:
if(Data.ContainsKey("area")
   && Data["area"] is int area)
{
    Debug.Log(area);
}

//And Add a property like this
Data.Add("area", 250);

A useful troubleshooting tip, is to breakpoint the keys to see what’s available for your objects.
I’m not 100% sure about GUIDs from revit, but if they appear in our Web viewer, they are accessible from within Unity.


In future, we were thinking that it might be nice to expose these properties to the inspector, and allow users to view/edit properties through the editor. But currently, the data is only accessible through code.

1 Like

Thank you very much for the reply! I will look into how to access the info on SpeckleProperties.

So I am trying to write a script that when attached to a Speckle Imported game object is able to access the SpeckleProperties component and return let’s say the value of the GlobalId. (I assume it would be the value associated with a key named “GlobalId” of the Data IDictionary, as you mentioned). See the images to see what property I am talking about:

GlobalId property of the IFC file:

GlobalId property imported to Speckle:

I am very new to C# so I am kinda messing with stuff I don’t fully comprehend here, but would something like this be the way to go?

I get some erros saying that the “Data” name does not exist in this context and that I am using unassigned local variable.

Would some script like this be the way to go to access this sort of properties within Unity?

Ah, sorry, there was a small mistake in the code sample I sent.
You should use props.Data not just Data.

Other than that, your code looks fine to me!

1 Like

Ok thank you. I still can’t get the if (props.Data.ContainsKey("KeyName")) to return true. I tried keys I know exist as I can see them in Speckle, like “id”, “Tag” or “Name” but it seems that the if never comes true. Maybe I am missing something still?

Ok, as a debug step, you could try printing all keys to the console.

Debug.log("printing keys:")
foreach(string key in props.Data.Keys)
{
    Debug.log(key)
}

Or if you are familiar with the debugger, you could try breakpointing the keys like I showed in a previous screenshot.

Also, the Id and speckle_type props are ignored, and won’t show up. but all other props should!


If you can’t get this to work, then I’d be happy to organise a quick call sometime this week.

Thank you! Using the foreach on the keys allowed me to see what was actually in there, and then using another Debug.Log I managed to get the value of some of the props, for example “elementId”.

When using my script on objects imported from Revit>Speckle>Unity it seems I can access most of the properties.

When I tried doing the same with Objects uploaded from IFC directly to Speckle via the import file option (IFC>Speckle>Unity) it seems some properties are missing, despite these properties showing up online in speckle. Most importantly in my case the “GlobalId” property is also missing.

I assume the Data dictionary in SpeckleProperties for the game objects originating from IFCs ends up getting generated differently which then causes some properties to not be present?

I would be very happy to have a quick call about this next week! It will be probably very helpful for me! How can we arrange this? Thanks in advance!

1 Like

Glad that you’ve been able to make some progress.

If the properties appear in the viewer, then they should be accessible from Unity, but I don’t think I’ve ever tested IFC → Unity, so there could be a bug somewhere :sweat_smile:

I’ll do some investigation, It might be useful for you to add me (jedd@speckle.systems) as a collaborator on that stream, so I can try receiving your IFC objects myself.


I’ll send you a direct message, and we can organise a time for a call.

1 Like