Search Unity

Question BIM Metadata - using stored data

Discussion in 'Unity Reflect' started by emmabnz, Jul 18, 2021.

  1. emmabnz

    emmabnz

    Joined:
    Jan 23, 2018
    Posts:
    5
    Hi there,

    I'm creating a custom stand alone VR application with an imported Revit prefab. At the moment I'm just using Reflect to maintain the link between the Revit project and Unity. However I'd really like to use the information stored within the Metadata script. I've created a small world space UI that pops up when a ray interactor is passed over an object. At the moment the text is inputted manually but i'd really like to be able to populate it with some of the data from the Metadata script. Is this possible? Does anyone have advice on how I can go about this? I'm reasonably new to Unity and C# ReflectHelp.PNG
     
    Last edited: Jul 18, 2021
  2. GSingland

    GSingland

    Unity Technologies

    Joined:
    Dec 10, 2020
    Posts:
    14
    Hi emmabnz,

    From what I understand, you're already quite close to what you want to achieve, if you already have the UI + the raycast.
    Therefore, I'm going to assume that, in your script, you already found the reference to the game object that contains the metadata you're interested to read. I hope this assumption is correct !

    Here's more or less what you're looking for if you want to iterate through the game object's metadata :
    Code (CSharp):
    1. Metadata metadata = gameObject.GetComponent<Metadata>();
    2. foreach (var couple in metadata.GetParameters())
    3. {
    4.     Debug.Log($"key: {couple.Key}");
    5.     Debug.Log($"value: {couple.Value.value}");
    6.     Debug.Log($"group: {couple.Value.group}");
    7. }
    Of course, you would replace the Debug.Log calls with you own code to populate your UI :)

    EDIT : I just realized you might also be looking for what you need to do to actually update the text in your UI ?
    There are many different threads on the web that can help you achieve this part, but the main idea is the following :

    Hope that helps,
    Guillaume
     
    Last edited: Jul 19, 2021
  3. emmabnz

    emmabnz

    Joined:
    Jan 23, 2018
    Posts:
    5
    Legend! thank you so much, really appreciate the quick reply!