Menu

How to find orientation of Ifc elements from top and bottom?

Help
2019-06-28
2020-12-16
1 2 > >> (Page 1 of 2)
  • Sabih Ahmad Khan

    Hi,

    I have gone through a research paper "Applying novelty detection to identify model element to IFC class misclassifications on architectural and infrastructure Building Information Models", published in Journal of Computational Design and Engineering (2018), which extracts data from IFC file for the analysis. I am able to extract area, volume and gyradius using IfcOpenShell and pythonOCC. How do I extract orientation from top and bottom of an Ifc element mentioned in this paper?

    I used the example given here to extract orientation of Ifc entity.

    import ifcopenshell
    import ifcopenshell.geom
    
    ifc_file = ifcopenshell.open('Duplex_A_20110907_optimized.ifc')
    
    settings = ifcopenshell.geom.settings()
    settings.set(settings.USE_PYTHON_OPENCASCADE, True)
    
    walls = ifc_file.by_type("IfcWall")
    
    shape = ifcopenshell.geom.create_shape(settings, walls[0])
    orientation = shape.geometry.Orientation()
    print(orientation)
    

    I am getting "0" for all Ifc entities. It seems I am calling wrong function to get the Orientation.

     
    • Hamid Kiavarz

      Hamid Kiavarz - 2020-11-20

      Hi Sabih,

      Can you guide me to get the area (surface area) and volume of a wall from ifc ?

       
      • Sabih Ahmad Khan

        Hi Hamid,

        After creating the BREP representation of the wall

        shape = ifcopenshell.geom.create_shape(settings, walls[0])
        

        you can use brepgprop_SurfaceProperties to find the surface area and brepgprop_VolumeProperties to find the volume of wall.

        Import the required modules:

        try:
            from OCC.Core import GProp, BRepGProp
        except ImportError:
            from OCC import GProp, BRepGProp
        

        then

        props = GProp.GProp_GProps()
        
        BRepGProp.brepgprop_SurfaceProperties(shape.geometry, props)
        surface_area = props.Mass()
        

        As mentioned here, if density is not provided then Mass() method returns
        - total area of the faces for surface properties and
        - total volume of the solids for volume properties

        BRepGProp.brepgprop_VolumeProperties(shape.geometry, props)
        volume = props.Mass()
        
         
        • Hamid Kiavarz

          Hamid Kiavarz - 2020-11-27

          Thanks Sabih, for the case of the related walls to a space which is a continiuse wall. which means, each part of wall is shared with different spaces. Is it possible to calculate the area of wall which is belong to a specific space ? sample in the attachment

           

          Last edit: Hamid Kiavarz 2020-11-29
        • Hamid Kiavarz

          Hamid Kiavarz - 2020-12-02

          Thanks Sabih. Finally, I could get the area and volume. IS it possible to have access to each face of a wall entity ? for example a wall has 6 faces and I need to access to each face along with its vertices separately.

           
          • Thomas Krijnen

            Thomas Krijnen - 2020-12-02

            http://academy.ifcopenshell.org/using-ifcopenshell-and-pythonocc-to-construct-new-geometry/

            But OCC.Utils.Topo does not exist anymore. Use OCC.Core.TopExp.TopExp_Explorer

             
            • Hamid Kiavarz

              Hamid Kiavarz - 2020-12-03

              OCC.Core.TopExp.TopExp_Explorer also is not available

               
              • Thomas Krijnen

                Thomas Krijnen - 2020-12-03

                OCC.TopExp.TopExp_Explorer depending on version of pythonocc

                 
  • Thomas Krijnen

    Thomas Krijnen - 2019-06-28

    Indeed, TopoDS_Shape.Orientation is something very specific. I think you're interested in the distance to other geometries?

    Have a look at the code here: https://github.com/IfcOpenShell/IfcOpenShell/pull/130 to find elements in the surroundings and use BRepExtrema_DistShapeShape to find distances. You also get a pair of points that you can use to see if the shapes are connected top to bottom.

     
  • Sabih Ahmad Khan

    Hi Thomas,

    Thanks for the quick response. I checked BRepExtrema_DistShapeShape which needs two TopoDS_Shape but as per the paper orientation is calculated for each individual element.

    The paper didn't mention how orientation is calculated but it seems to be an angle that Ifc elements make with True North.

    Reference: About the Geo-referencing of BIM models.

     
  • Thomas Krijnen

    Thomas Krijnen - 2019-07-03

    Short answer: You can look at the ObjectPlacement, it defines the orientation of the element relative to the parent element.

    Long answer: I'm confused, your question title states something about Top and Bottom? To me it seems rotation relative to True north is not a very useful feature to identify element types. After all, a wall could be oriented in every direction. I can imagine if you determine something like proportions of an element you can easily segment walls from slabs, but that should already be covered by the more general geometry properties anyway.

    But we're just speculating about some paper's intentions now. If you have specific questions I can be of better help.

     
  • Hamid Kiavarz

    Hamid Kiavarz - 2020-11-22

    Dear team,

    I am using python 3.8 and try to get the geometry from Ifcopenshell. I am getting below error when I used settings.set(settings.use_python_opencascade, True) :

    AttributeError: 'settings' object has no attribute 'use_python_opencascade'

    please direct me how I can solve the issue

     
    • Thomas Krijnen

      Thomas Krijnen - 2020-11-24

      use_python_opencascade should be UPPERCASE. In addition make sure you have the pythonocc-core python module installed for the setting to be available.

       
      • Hamid Kiavarz

        Hamid Kiavarz - 2020-11-24

        thanks Thomas. I have already installed pythonocc but still getting the error of "'settings' object has no attribute 'use_python_opencascade'". Any clue ?

         
  • Sabih Ahmad Khan

    Hi Hamid,
    It seems you are using

    settings.set(settings.use_python_opencascade, True)
    

    As mentioned by Thomas, please change this to

    settings.set(settings.USE_PYTHON_OPENCASCADE, True)
    
     
    • Hamid Kiavarz

      Hamid Kiavarz - 2020-11-26

      Hi Sabih.

      I tried both but still getting same error.

       
      • Sabih Ahmad Khan

        Hi Hamid,

        There might be installation issue with your packages. Please try with new installation:

        Create a new environment:

        conda create --name=pythonocc-core python=3.8
        

        Activate the environment:

        conda activate pythonocc-core
        

        Install pythonocc-core 7.4.0:

        conda install -c conda-forge pythonocc-core=7.4.0
        

        Download the appropriate version of IfcOpenShell-python from url under 0.6.0 latest:
        For windows (64bit): IfcOpenShell-python for python 3.8 64bit Windows
        For Linux (64bit): IfcOpenShell-python for python 3.8 64bit Linux

        Unzip and save ifcopenshell folder in site-packages of the conda environment:
        For windows: C:\Users\user\anaconda3\envs\pythonocc-core\Lib\site-packages
        For Linux: /home/user/anaconda3/envs/pythonocc-core/lib/python3.8/site-packages

        I tested the above steps. It works fine without any error.

         
    • Hamid Kiavarz

      Hamid Kiavarz - 2020-11-26

      Hi Sabih,

      Thanks for your advice, I have tried the capital letters as well but still
      getting the same error.

      On Tue, Nov 24, 2020 at 11:11 AM Sabih Ahmad Khan sabihahmadkhan@users.sourceforge.net wrote:

      Hi Hamid,
      It seems you are using

      settings.set(settings.use_python_opencascade, True)

      As mentioned by Thomas, please change this to

      settings.set(settings.USE_PYTHON_OPENCASCADE, True)


      How to find orientation of Ifc elements from top and bottom?
      https://sourceforge.net/p/ifcopenshell/discussion/1782717/thread/fce1ec37c2/?limit=25#7f6d


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ifcopenshell/discussion/1782717/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Hamid Kiavarz Moghaddam
      Email: hkiavarz@gmail.com
      Email: hkiavarz@yorku.ca
      +1 647-807-8909

       
      • Thomas Krijnen

        Thomas Krijnen - 2020-11-28

        What's the output of the following as individual commands, so run each of them separately:

        import OCC

        import OCC.BRep

        import OCC.Core.BRep

        print(dir(settings))

         
        • Hamid Kiavarz

          Hamid Kiavarz - 2020-11-28

          Nothing
          No module named 'OCC.BRep'; 'OCC' is not a package
          No module named 'OCC.Core'; 'OCC' is not a package
          module 'ifcopenshell' has no attribute 'geom'

           
          • Thomas Krijnen

            Thomas Krijnen - 2020-11-28

            Then are you sure you have pythonocc installed? How did you install it?

             
            • Hamid Kiavarz

              Hamid Kiavarz - 2020-11-28

              I do. I followed the steps that Sabih mentioned in the upper comments :

              onda create --name=pythonocc-core python=3.8
              Activate the environment:

              conda activate pythonocc-core
              Install pythonocc-core 7.4.0:

              conda install -c conda-forge pythonocc-core=7.4.0.

               
            • Hamid Kiavarz

              Hamid Kiavarz - 2020-11-29

              here is the folders I have in site-package

               
              • Thomas Krijnen

                Thomas Krijnen - 2020-11-29

                But then I can't explain:

                No module named 'OCC.BRep'; 'OCC' is not a package
                No module named 'OCC.Core'; 'OCC' is not a package
                

                What's the contents of the OCC folder? Are you sure you're using the correct env and python interpreter when importing? I.e what does the following say:

                import sys
                print(sys.executable)
                import site
                print(site.getsitepackages())
                print(site.getusersitepackages())
                
                 
                • Hamid Kiavarz

                  Hamid Kiavarz - 2020-11-30

                  here is teh result and find the content of OCC in the atatchment:

                  C:\Users\Malavan-PC\AppData\Local\Programs\Python\Python38-32\python.exe
                  ['C:\Users\Malavan-PC\AppData\Local\Programs\Python\Python38-32', 'C:\Users\Malavan-PC\AppData\Local\Programs\Python\Python38-32\lib\site-packages']
                  C:\Users\Malavan-PC\AppData\Roaming\Python\Python38\site-packages
                  PS C:\Users\Malavan-PC\OneDrive - York University\Coding>

                   
1 2 > >> (Page 1 of 2)

Log in to post a comment.