Skip to content

Decouple data and usecases from BlenderBIM Add-on #1399

Description

@Moult

As the BlenderBIM Add-on now does native IFC authoring, a portion of its code is 100% agnostic of Blender. I believe there is value in:

  1. separating the agnostic code into its own module
  2. introducing unit tests to make sure the code does what it does
  3. using that code to then generate IFCs which can then form unit tests for whatever else we think is useful instead of having huge test model repos
  4. polishing a super duper user friendly api for users over time to manipulate and generate ifcs at a higher abstracted level (that also considers schema differences out of the box) than the current offerings (e.g. pure ifcopenshell, and ifcopenshell utils) - this means refining how these usecases are called and even writing (gasp) documentation!
  5. Maybe we can even generate some visual nodes for this. Neat.
  6. Some higher level functions are useful in other utilities (e.g. currently ifccsv does its own pset and attribute editing - but with this higher level API it could do it better by considering ownership histories.)

The current system architecture is formed by dividing up the IFC schema into "modules" that delineate logical aspects of an IFC model that you might modify. For example, there is a module that manipulates the psets concept, and this is totally separate from a module that manipulates the classification references concepts.

Each module treats IFC as the source of truth. Two things are provided. There is a "Data" class for each module, which offers an abstraction to load useful information related to that module. It reads data from the IFC, and returns simple Python dictionaries and regular Python data types. The user can then use this as a cache of data, or a way to bulk load useful data without needing much knowledge of the IFC spec.

Each module also provides zero or more usecases. A usecase is a particular scenario where you might want to modify / write data to the IFC. It is higher level as it will take into account things like type conversions, maintaining ownership histories, purging trees as necessary, etc.

Here's a diagram of how the Blender-agnostic "Data" reading and "Usecase" writing concepts (purple) currently interacts with the BlenderBIM Add-on code (in orange)

image

Purple lines are data that use IfcOpenShell objects. Dark grey lines are data that are plain old Python Objects (POPOs) that aren't magical at all. Orange lines are data that uses Blender-specific data structures. Note how there is no coupling between Data (reading) and Usecase (writing).

Here is an example usecase for editing georeferencing and a data class for georeferencing.

The code is already written, but I want to propose splitting the BlenderBIM Add-on code from this core code, as currently the files are in the same place. Also the imports currently all have "blenderbim" in the namespace which isn't quite semantically correct :) This makes it difficult for a newcomer to simply include this library when they don't care about Blender.

So, this issue is to find out:

  1. Is there anyone who thinks this shouldn't be done?
  2. Any preferences on how this is bundled? Should it be part of the ifcopenshell python module, or should it be another module that is like an "api" to IfcOpenShell? Maybe import ifcopenapi? :) (literally thought of that as I'm typing this, no ideas yet)
  3. Does this sound like an initiative that have some direct impact to something you're working on? Perhaps with the unit tests?

I was inspired to write this since @fbpyr seems to already be doing a lot of magical IFC generation and is using these usecases (currently through Blender operators, but effectively he is using these usecases).

Refactoring this is currently a low priority though, as nobody is jumping up and down for this just yet :) And the code kinda just needs moving and search/replace for imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions