TBC Macros and Extensions

 View Only
Expand all | Collapse all

IFC handling has been changed, again - how to retrieve the triangulated face list?

  • 1.  IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 24 days ago

    Those undocumented changes are so annoying.

    It's now relative simple to retrieve the single triangles with ShellMeshData.GetTrianglesForInspectionInternal. That is enough for some use cases.

    But for my explode IFC macro I need a list with the vertices and a list with the triangulation information between those vertices. Makes it simpler to filter out duplicate lines.

    Previously that was possible with ShellMeshData.GetFaceList() and GetVertex().

    GetVertex() is now GetVertexList()

    But how do I get the triangulation list.

    The ShellMeshData object does have a protected list m_TriangulatedFaceList, but how could I access it?

    For now I have to reverse engineer that list by taking the point information from GetTrianglesForInspectionInternal and finding their index in the list I get from GetVertexList.



    ------------------------------
    Ronny Schneider
    ------------------------------


  • 2.  RE: IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 23 days ago

    The IShell3DData.GetIndices() method now takes a TriangulationContext parameter.

    Elisha sent out an email last December documenting these changes.



    ------------------------------
    https://tbcanz.com/anz-toolbox/
    ------------------------------



  • 3.  RE: IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 23 days ago

    Thanks,

    I'll have a look tonight.

    Who is Elisha? How do I get onto that mailing list?



    ------------------------------
    Ronny Schneider
    ------------------------------



  • 4.  RE: IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 20 days ago

    So, I had a look, and it does work as before. You now even have the option which list to retrieve.

    0 - The Faces as defined in the IFC, where I have seen faces which were defined of dozens of vertices

    1 - the triangulated list, but still with the integer 3 in front of every vertex triplet [3, v1, v2, v3, 3, v1, v2, v3 ...]

    2 - the triangulated list but without the 3 and really just the vertex indices [v1, v2, v3, v1, v2, v3 ...]

    There is a new enumerator you need to import.

    try: # new in 2024.00
        from Trimble.Vce.Interfaces import TriangulationContext
    except:
        pass
    

    A selected IFC object can be made up from several sub-meshes. You'll need to loop through them.

            self.ifcType = clr.GetClrType(BIMEntity)
    
                       for o in self.ifcs.SelectedMembers(self.currentProject):
    
                            if isinstance(o, self.ifcType): # in case it is an IFC Mesh we get us the coordinates
    
                                for shellMeshInstance in o.GetGeometry():
    
                                    shellMeshData = shellMeshInstance.GetShellMeshData()
    
                                    # DEPENDING ON THE TYPE OF IFC THE DIFFERENT METHODS RETURN EMPTY LISTS
                                    try: # prior to 2024.00
                                        vertexIndices = shellMeshData.GetTriangulatedFaceList() # this works for the bridge IFC
                                        if vertexIndices.Count == 0:
                                            vertexIndices = shellMeshData.GetFaces()    # this works for the geotech, but not the bridges
                                        verticiesLocal = shellMeshData.GetVertex() # verticies as Point3Ds
                                        verticiesGlobal = []
                                        for v in range(0, verticiesLocal.Count):
                                            verticiesGlobal.Add(shellMeshInstance.GlobalTransformation.TransformPoint(verticiesLocal[v]))
    
                                    except: # new for 2024.00
                                        verticiesGlobal = shellMeshData.GetVertexList(shellMeshInstance.GlobalTransformation)
                                        vertexIndices = shellMeshData.GetIndices(TriangulationContext(1)) # triangulationContext 0 - NonTriangulated; 1 - Triangulated; 2 - TriangulatedImplicit without the length entry 3
    
    
    

    For my ExplodeIFC macro I prefer to have the vertex indices since I can just throw the start/end integers into a list

    linetuples.Add([vertexIndices[t+1], vertexIndices[t+2]])

    Once I'm done doing that this list contains probably duplicates, but you can get rid of them very easy with

    linetuplesclean = list(set(map(lambda i: tuple(sorted(i)), linetuples)))

    That even sorts out lines which are defined the reverse way, i.e. [1,2] and [2,1] are considered the same and just one remains. In that case perfect for what I'm doing and very fast.



    ------------------------------
    Ronny Schneider
    ------------------------------



  • 5.  RE: IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 13 days ago

    Hi Ronny,
    I've sent in your request for being kept in the loop for IFC development changes during our dev cycle. Hopefully this limits upcoming headaches!



    ------------------------------
    Bryce Haire
    ------------------------------



  • 6.  RE: IFC handling has been changed, again - how to retrieve the triangulated face list?

    Posted 12 days ago

    Hello Bryce,

    thanks for that.



    ------------------------------
    Ronny Schneider
    ------------------------------