TBC Macros and Extensions

 View Only
Expand all | Collapse all

a rare present did popup in the library section - a detailed insight on the IFCMesh class with screenshots and sample code

  • 1.  a rare present did popup in the library section - a detailed insight on the IFCMesh class with screenshots and sample code

    Posted 01-21-2025 23:51

    Only stumbled across that one by total chance. I rarely check the library or blog section since there haven't been any interesting entries in ages. And new entries don't get highlighted enough (it's somewhere at the very bottom of the community front page) and the standard sorting direction of the library is "A-Z" and not by creation date. So, total luck that I found that one.

    details on the IFCMesh class

    @David Kosakowski Thanks for that, and we need more of that sort, especially point cloud handling/processing/structuring comes to mind. But please find a better way to highlight/announce vital information like that.



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


  • 2.  RE: a rare present did popup in the library section - a detailed insight on the IFCMesh class with screenshots and sample code

    Posted 01-23-2025 10:03
    Edited by David Kosakowski 01-23-2025 10:13

    Thanks for the feedback, Ronny. The best way to stay up-to-date is to enable notifications for new content in each of your communities:

    1. Click your profile picture in the upper right.
    2. Select My Account > Community Notifications.
    3. Scroll down and check the boxes to receive either daily or weekly digests.

    You will then get emails when new posts appear. 

    You are correct that the newly shared files are a bit hidden, but they do appear chronologically on the lower-right side of the home page when you scroll down.

    ------------------------------
    David Kosakowski



  • 3.  RE: a rare present did popup in the library section - a detailed insight on the IFCMesh class with screenshots and sample code

    Posted 01-29-2025 15:59

    Thanks David, I'll play around with the Notification settings.

    I finally had some time to go through that documentation and converted my existing 2024 code to the new one. I was surprisingly close with my trial and fail.

    To consolidate the info here some sample code on how to create new IFC objects.

    The tree in the project explorer is handled by Trimble.Vce.Data.Construction.IFC.BIMEntityCollection, and here you keep adding Trimble.Vce.Data.Construction.IFC.BIMEntity to each other.

            bimEntityColl = BIMEntityCollection.ProvideEntityCollection(self.currentProject, True)
    
            bimprojectEntity = bimEntityColl.Add(clr.GetClrType(BIMEntity))
            bimprojectEntity.EntityType = "IFCPROJECT"
            bimprojectEntity.Description = ifcprojectname # must be set, otherwise export fails
            bimprojectEntity.BIMGuid = Guid.NewGuid()
    
            bimobjectEntity = bimprojectEntity.Add(clr.GetClrType(BIMEntity))
            bimobjectEntity.EntityType = "IFCBUILDINGELEMENTPROXY"
            bimobjectEntity.Description = ifcshellgroupname
            bimobjectEntity.BIMGuid = Guid.NewGuid()
            bimobjectEntity.Mode = DisplayMode(1 + 64 + 128 + 512 + 4096)
            # MUST set layer, otherwise the properties manager will falsly show layer "0"
            # but the object is invisible until manually changing the layer
            bimobjectEntity.Layer = layer 
    

    A mesh object is created/stored in Trimble.Vce.Data.ShellMeshDataCollection

            shellMeshDataColl = ShellMeshDataCollection.ProvideShellMeshDataCollection(self.currentProject, True)
            shellmeshdata = shellMeshDataColl.AddShellMeshData(self.currentProject)
            # ifcnormals = Array[Point3D]([Point3D()]*0)
            # don't know why you'd need Normals, since they are defined by the faces and their counter or clockwise definition anyway
            shellmeshdata.CreateShellMeshData(ifcvertices, ifcfacelist, ifcnormals) 
            shellmeshdata.SetVolumeCalculationShell(ifcvertices, ifcfacelist) # unclear if this is necessary
    

    Each mesh has its own serial number. In order to see it on the screen we add a Trimble.Vce.Data.ShellMeshInstance to the appropriate BIMEntity in the tree. This tells that part in the IFC tree to show this specific mesh to be visible at a specific location/transformation.

            meshInstance = bimobjectEntity.Add(clr.GetClrType(ShellMeshInstance))
            meshInstance.CreateShell(0, shellmeshdata.SerialNumber, Color.Red.ToArgb(), transform)
    

    You can reference the same mesh to multiple BIMEntity with a different transformation each time.

    In this example the "transform" is a basic Matrix4D(), since my "ifcvertices" list contains absolute/final coordinates.

    The "ifcvertices" is a simple list of Point3D

    The "ifcfacelist" is a collection if integers, referencing back to "ifcvertices"

    facelist example from a washer object



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