Molior tool and file format for generating IFC data
[ For background, see this thread on @topologic ]
Molior is a tool developed to create usable 3D models from building designs generated by Homemaker, but it is designed to work independently of Homemaker and can be used to generate IFC models from simple text definitions.
Molior uses as input an undocumented (until now) intermediate file format with a YAML structure called .molior
. It outputs 3D DXF, Collada or IFC data. Molior is a perl module that depends on two other non-standard perl modules: File::IFC and File::DXF.
molior-ifc.pl
is a command-line tool, it accepts one or more .molior
files as input and outputs a single .ifc
file as output. It requires some style information, default profiles, windows and doors that are found in a folder called share
in the Molior sources. You will need to set the path to this folder in your environment before running the tool:
$ export SHARE_DIR=~/src/molior/share
$ molior-ifc.pl interior_wall.molior interior_wall.ifc
Here is a really simple .molior
file that defines a single segment interior wall with a door in it:
---
type: molior-wall
guid: abcdefghijklmnopqrstuvwxyz
level: 0
name: interior
closed: 0
elevation: 3.0
height: 3.0
ceiling: 0.2
floor: 0.02
inner: 0.08
outer: 0.08
path:
-
- 30.8
- 17.8
-
- 25.457
- 15.935
openings:
-
- along: 0.45
name: kitchen inside door
size: 0
I hope most of this is obvious:
---
just indicates that the following data is a YAML stream.molior-ifc.pl
will accept multiple files as input, or they can be concatenated into a single file separated by---
.type: molior-wall
just says that this isn't a ceiling.guid
is a string that identifies which building (of potentially several) this element belongs-to.level
is the building storey this element belongs-to, ground floor is 0, the floor above ground is 1.name: interior
this is used to tag this wall as.INTERIOR.
in the IFC file.closed: 0
indicates that this wall doesn't form a loop (this example only has one segment, so setting this to 1 may cause undefined problems).elevation
is the absolute level of the bottom of the wall (this is the implicit level of the storey, metres).height
is the floor to floor height of the wall (metres).ceiling
andfloor
indicate the space at the top and bottom of the wall that is obscured by structure, where we can't put windows and doors (metres)inner
andouter
are the offsets from the centreline for the two faces, this is an interior wall so the values are the same (metres).path
is a list of X and Y coordinates that define 2D position of the wall (at least two entries, metres).openings
is a list of wall segments, each segment contains a list of needed windows and doors. Molior picks the door from a database of doors, it will shuffle it around and even switch to a smaller door if it doesn't fit; so thename
field is the class of door we want (from the database),size
is which door in the class we prefer, 0 is the first, andalong
is where we want it (metre distance from start of the segment). Notice that I haven't implemented left and right swings etc.. yet. You don't need to know exactly where you want the door, setalong
to 0.0 or 20.0 and the door will be shuffled to the start or end of the segment (with the amount of clearance defined in the style database).
This is what the IFC output looks like in blenderbim:
Comments
Here's a slightly more complex wall defined by Molior:
This is an external wall, so notice that the
outer
offset from the centreline is larger than theinner
, also note that I'm drawing the wall anti-clockwise, otherwise the outside would be on the inside (for a closed courtyard you would draw the wall clockwise). Some of the wall segments don't have windows or doors, this is just an empty item in theopenings
list.Here is the IFC output based on this definition. There are a couple of segments where I specified less windows, but Molior decided that there was room for more windows! This is intentional behaviour as it suits the kind of buildings I'm working with. It does mean that you don't need to make any kind of calculation about how many windows you need, just throw a window and/or a door at a segment and Molior will sort it out.

It is all skinnable, shown is a vaguely northern European style, I have also implemented a vaguely north African dry climate style.
Thank you @brunopostle, I don't have any view about Perl, but as far as I see, that YAML approach is: "Templates" and using the template which is a known method in Object-Oriented Programming to generate the scene
Indeed, it's (somewhat) "scene graph"
This is great and very clear. I think I can work with that. So as an experiment, I can take a Topologic entity and will try to write a small python script to output the molior file and upload it here. You can then test if it creates something architectural! My only question is the indents and the "-" What are the rules surrounding these?
Sorry @brunopostle one more question: is 'along' measured from the start of the edge to the start of the opening or to its centre?
@topologic
YAML is a data serialisation format, with similar scope to JSON, except it is a bit more human-readable:
It is easy to generate with print statements or even a text editor, but there will be a YAML library for whatever framework you are using.
It is to the start of the opening