Introducing bonsai salad
Hello!
I'm playing with ai to create some scripts that improve my workflow and i thought to share them with a blender addon, that is easy to install and to tryout, until something can be mature enough to eventually be pushed to upstream via PR.
At the moment i'm focusing on pdf generation (sheets to pdf with typst) and DXF drawing production with ezdxf.
https://github.com/carlopav/bonsai_salad/releases/tag/v0.0.1
Ifc_dxf, exports Bonsai plan views directly to DXF without relying on OCC or tessellation. The core idea is to map IFC semantics onto DXF structure as faithfully as possible, maximising the editability of the output file.
Elements that carry a native 2D plan representation — windows, doors, furniture, sanitary fixtures — are exported as exact DXF BLOCK definitions referenced by INSERT entities. Geometry is extracted directly from the IFC graph (IfcMappedItem, IfcIndexedPolyCurve, IfcTrimmedCurve) producing true LINE, ARC, CIRCLE and ELLIPSE entities with no approximation. Each IFC type maps to one block, identified by its Name; each instance becomes an insert on its own layer, so the DXF mirrors the IFC object hierarchy.
Walls are handled separately: their section polygon is reconstructed from IfcExtrudedAreaSolid, openings are subtracted via Shapely, and the result is written as LWPOLYLINE outlines and solid HATCH fills — grouped by material, ordered for correct draw priority.
Additional rules handle slab occlusion (XY footprint check, multi-building safe) and overhead elements (windows above the cut plane drawn dashed on dedicated layers). All block entities use BYBLOCK attributes so the INSERT layer fully controls colour, linetype and lineweight.
Nothing is ready for production, but if you want to try out let me know what you think.









Comments
cool!.. is anything ever ready for production. ;)
Hell yeah, I love salad :D
Pretty cool! One of the issues of stopping over SVG/PDF to reach DXF is that true circles are often lost and become splines, which is less than ideal (no explicit center point, no quadrants, hard to snap to, or work with).
Awesome work!
Thanks @duarteframos !
There is another interesting (i think) approach: almost no options panel to customize the output, but a dxf template where the user can set his text, dimensions, layer styles, that is then used to populate the exported drawings. I created it with bricscad in DXF2010ASCII format, so it takes into account annotative dimensions and texts. Last release has a zip file that can be installable via blender preference. The addon itself is a side n-panel.
That is interesting!
What is actually read from this template? I assume DXF layer names are taken from IFC types, then the style of such layers (color, linetype, linewidth) are taken from this template file, is that correct?
Or is this template somehow parsed to read layer names from it? If so, how are IFC types then mapped to the corresponding layer, is there a way to customize it?
On a tangentially related note; you addon focuses on the DXF output side, but out of curiosity would those DXF libraries somehow allow the reverse, as in DXF input? I'm thinking of eventually having a way to import DXF data directly into native IFC data structures like indexed polylines for say arbitrary profiles, or annotations (for auxiliary drawings) or as walls.
As far as I understand it, currently importing DXFs into Bonsai has to be done through Blender DXF importer and loses most data along the way as it goes through conversion into mesh or bezier curve.
Don't let perfection get in the way of productivity
Yes, the template (attached here) is already populated with layers named according to IfcClasses (IfcWall_Section, IfcWall_Hatch, IfcWallView, etc, IfcWindow, IfcWindow_Overhead, etc. it's still not completely defined, i'm changing along the way). Color, linetype etc are taken from the template. Same goes for dimension style, text style: the template already has the style and it is assigned to the annotation when exported. Also a layout is present and it's populated with correct scale, date and drawing name, so it's quicky printable.
This is an interesting topic, the add-on rely on ezdxf for dxf writing. The library can also read from dxf. I think we could easily import:
1. Annotations. Useful for importing auxiliary drawings, reference overlays, or any 2D annotation layer, perhaps even only the dimensions of a drawing.
2. Representation context of an existing element. The user selects an IFC element in Bonsai and a DXF source. The DXF geometry is attached as a new IfcShapeRepresentation on the element's IfcProductDefinitionShape, with the identifier (FootPrint, Body, Axis, Profile) chosen by the user. No semantic guessing needed — Bonsai already knows what the element is.
3. Just thinking out loud, if the dxf provides semantic informations, some kind of 2d ifc could be eventually created. (?)
That was exactly what I had in mind, forgot about IfcShapeRepresentation but those are actually one of the most desirable targets.
According to https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/lexical/IfcProductDefinitionShape.htm they even support presentation layers, maybe those can be leveraged for visual styles or semantic data. Not sure if its possible, but I was imagining if one could read block data from DXF, maybe it could eventually use blocks names for importing various IfcShapeRepresentation from a single DXF file, and have them assigned to the correct identifier (FootPrint, Body, Axis, Profile, etc) without guessing, maybe later bonsai allows overriding/editing, in case of error or needed changes.
Annotations, reference drawings (plans, elevations, etc) when converting existing CAD data to IFC, land surveys, contour lines/isolines are also good candidates. Along with profile definitions for more complex sections not easily defined by the builtin parametric shapes.