Search Unity

Unity + BIM data?

Discussion in 'Scripting' started by Maximvs, Nov 6, 2018.

  1. Maximvs

    Maximvs

    Joined:
    Oct 10, 2016
    Posts:
    10
    Hi Guys,

    Some people have asked how to get BIM data in your Unity Project. This is how to do it.

    First export your BIM model as IFC 2x3 and upload it to Tridify Convert (https://www.tridify.com/convert/).
    After the conversion is ready, download Tridify Tools plugin from Asset Store.
    With the plugin import your BIM model to Unity scene.

    I created this simple C# script as an example, how to show BIM data in runtime, just by clicking a gameobject.
    When clicking an object in the game window, the script will print BIM data to the console.

    ForumPostCapture.PNG

    Few things for you TODO.

    - Add the script to a gameobject Eg. the Main Camera
    - Link Main Camera gameobject from hierarchy to ShowBimData.cs script RaycastCamera public field in Inspector
    - Add colliders to all mesh objects as I'm using raycast in the script!

    Code (CSharp):
    1. using UnityEngine;
    2. using Tridify;
    3. using System;
    4. using System.Linq;
    5.  
    6. public class ShowBimData : MonoBehaviour {
    7.  
    8.     public Camera raycastCamera;
    9.     private GameObject _selectedObject;
    10.  
    11.     void Update()
    12.     {
    13.         if (Input.GetButtonDown("Fire1"))
    14.         {
    15.             Ray ray = raycastCamera.ScreenPointToRay(Input.mousePosition);
    16.             RaycastHit hit;
    17.  
    18.             if (Physics.Raycast(ray, out hit, 1000))
    19.             {
    20.                 _selectedObject = hit.transform.gameObject;
    21.  
    22.                 var ifcType = _selectedObject.GetComponent<IfcType>();
    23.  
    24.                 if (ifcType != null)
    25.                 {
    26.                     var attributeStrings = ifcType.Attributes
    27.                         .Select(attr => attr.Name + ": " + attr.Value);
    28.                     var attributesString =
    29.                         string.Join(Environment.NewLine, attributeStrings);
    30.  
    31.                     Debug.Log("Selected: " + ifcType.GetType().Name
    32.                         + Environment.NewLine + attributesString);
    33.                 }
    34.                 else
    35.                 {
    36.                     Debug.Log("No IfcType found on object " + _selectedObject.name);
    37.                 }
    38.             }
    39.             else
    40.             {
    41.                 Debug.Log("");
    42.             }
    43.         }
    44.     }
    45. }
    46.  
     
    Last edited: Nov 7, 2018
    TW2000 likes this.
  2. Maximvs

    Maximvs

    Joined:
    Oct 10, 2016
    Posts:
    10
    Hi Guys, for some unknown reason Unity has removed our Tridify BIM Tools plugin from Asset Store.
    But don't worry, You can still download Tridify BIM Tools plugin from here https://www.tridify.com/developers/unity/

    Cheers!
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,981
    Less keen on downloading something if its not allowed on asset store. Did they confirm to you that its a mistake, or is it because it breaks their TOS?
     
  4. Maximvs

    Maximvs

    Joined:
    Oct 10, 2016
    Posts:
    10
    Unity haven't given us any explanation for taking our plugin out of Assets Store, but we're investigating this issue as we speak.
     
  5. Miia_Tridify

    Miia_Tridify

    Joined:
    Oct 4, 2018
    Posts:
    6
    Because our service is an online, cloud-based service, that requires a user to register and sign in, and since our Asset Store Partner Agreement with Unity ended, we are not qualified in Asset Store anymore (Submission Guidelines, section 1.4).
    We are sorry for any inconvenience.
    We will continue to develop and support our tools and, like said earlier, You find Tridify BIM Tools for Unity here:
    https://www.tridify.com/developers/unity/