Sharing code between FreeCAD and BlenderBIM

As first proposed by @bernd over at the FreeCAD forums, I think it's a great idea to share code between FreeCAD and BlenderBIM. I'm posting to start the discussion off with a very simple draft proposal of a new set of utility classes and functions which will be part of IfcOpenShell, which we can then use.

Here's a few ideas off the top of my head just to get started (definitely full of holes!), we can then organise them into classes (perhaps ifcopenshell.util.material , ifcopenshell.util.qto (do automagic calculations?) and ifcopenshell.util.pset , etc etc

  • get_material(element)
  • get_unit_scale() - stuff related to SI and imperial unit conversions and all that
  • convert_unit()
  • get_property() - note this needs to handle not just simple properties but complex list and tabular properties too - also qto can be merged into this since buildingSMART is planning to merge them anyway for IFC5
  • calculate_volume/area/length()?
  • convert_true_north_angle()?
  • fetch_epsg()?
  • dd2dms() and dms2dd() definitely
  • local_to_global(coordinate)?
  • map_class(element) - e.g. mapping between IFC classes and uniclass, omniclass, AIA CAD layers ...

In addition, various utilities can be shared:

  • IFC diffing
  • IFC COBie
  • IFC CSV spreadsheet export
  • IFC recycling / garbage collector
  • Ifc Patching


bitacovirJesusbillpaullee

Comments

  • @Moult said:

    IFC CSV spreadsheet export

    Has there been any progress for this with FreeCAD?

    paullee
  • Ping @yorik :)

    This thread is a little old, and there's been a ton of new additions since then too! Exciting times!

  • Great! Let's revive the subject! :)

    MoultbitacovirAcepaullee
  • edited January 2022

    Great news :)

    Incidentally, it seems there are some bugs and crash in FreeCAD without enough resources to be tackled - anticipate the sharing improve efficiency in utilitisation of IFC and add synergy in both application. I hope I understand IFC but it proves too difficult for me at the moment :(

  • Even Autodesk finds IFC too difficult for them. Don't feel bad @paullee :D

    CoenLaurensJNberndpaulleeMoultAce
  • Want to pitch in here. IFC import seems to take quite a while in Revit with, eg. one of the sample Archicad projects. In Blender it imports pretty fast.
    I imagine it may be mesh straightforward representation vs FC trying to rebuild everything in solids?

  • The main speed hog in FreeCAD is when building the GUI objects, probably because there it needs to connect a lot of Qt signals. As a proof of that theory, if you import an IFC file in console mode, it is very fast, similar to Blender.

    The strategy i want to try aftwr the 0.20 release is to allow to import an IFC file GUI-less even if you are using the GUI, store the result in an (or several, ex one per floor) external file and xref that file into the current document. This should give us huge speed gains and allow to work with very large files

    dimitar
  • edited April 2022

    There are a few things which allow IfcOpenShell, via the BlenderBIM Add-on, to process IFCs very quickly.

    1. We use the IfcOpenShell geometry iterator with context filters. This C++ code is very fast and the context filters can even double the speed if there are unnecessary geometric contexts to process (esp. structural models). Additional geometric context loading is done after the project has been loaded.
    2. We use IFC natively. This means that whereas Revit and FreeCAD are importing data, we only process geometry (and materials). All other IFC data is loaded on-the-fly as the user requests it in the UI. I know many people think geometry is always the bottleneck, but honestly skipping all the metadata loading and relationships easily makes opening projects twice as fast.
    3. We use multiprocessing in C++ with all cores. I think Revit only uses a single core.
    4. We minimise Python when interacting with Blender. We provide data to Blender using foreach_set which is significantly faster because it goes directly to the way Blender's C code likes things. We also minimise UI interactions. For example, collection linking or anything that triggers a Blender depsgraph update is delayed until the last moment.
    5. We allow for lazy loading. Because we use IFC natively, we don't need to load everything. We allow project import filters so you can just load a portion of the model.
    6. We use a HDF5 cache so that subsequent reloads don't recalculate cached geometry.
    7. We've been working hard on profiling and optimising the iterator code in IfcOpenShell. Depending on the version of IfcOpenShell shipped with FreeCAD and the options used in their iterator, they might get some of these benefits for free already which is awesome :D
    8. A few things like swept disks are treated specially because Blender curves are super fast. I believe FreeCAD also already does this trick, very common for rebar.

    Not all of these apply to FreeCAD, but a number of these I believe aren't used in FreeCAD yet and the BlenderBIM Add-on is proudly serving as a testing platform :) Things like context filters and HDF5 cache are probably things FreeCAD can implement very easily after we've been battle testing it for a good half a year or so.

    GorgiouspaulleetheoryshawdimitarJesusbill
  • @yorik said:
    Even Autodesk finds IFC too difficult for them. Don't feel bad @paullee :D

    Autodesk is in the process of switching to the ODA IFC libraries - so let's hope for some improvement. They already say there are speed improvements.
    As many of you may have hear Richard Petrie of bS died recently, he was a nice guy who has played a big part in building bS to what they are today.

  • edited April 2022

    @dimitar said:
    Want to pitch in here. IFC import seems to take quite a while in Revit with, eg. one of the sample Archicad projects. In Blender it imports pretty fast.
    I imagine it may be mesh straightforward representation vs FC trying to rebuild everything in solids?

    I don't understand why 'speed' still is not a creterium for IFC developments and cerfification. It is curial and very important if you want people to work with it.

  • @yorik said:
    The strategy i want to try aftwr the 0.20 release is to allow to import an IFC file GUI-less even if you are using the GUI, store the result in an (or several, ex one per floor) external file and xref that file into the current document. This should give us huge speed gains and allow to work with very large files

    @Moult said:
    There are a few things which allow IfcOpenShell, via the BlenderBIM Add-on, to process IFCs very quickly.

    Happens to be a post about IFC import speed in FreeCAD forum :D

    https://forum.freecadweb.org/viewtopic.php?f=39&t=68196#p590272

    bitacovir
Sign In or Register to comment.