BlenderBIM Add-on/Using the Python console with BlenderBIM Add-on
|This page is part of a series about Starting to code. All articles in the series can be found in the Category:Start_coding|
The BlenderBIM Add-on comes with my useful Python libraries to interrogate BIM data, in addition to the math and geometry libraries that Blender comes with. A short list of these additional libraries is provided:
- ifcopenshell - used for querying, writing, and manipulating IFC data and files
- bcfplugin - used for querying, writing, and manipulating BCF data and files
- fcl - used for writing custom logic for clash detection
- OCC - used or directly accessing the Open CASCADE geometry kernel for low-level geometric analysis
- svgwrite - used for writing SVG for construction documentation
- ifcdiff - used for comparing IFC files for changes
- ifccsv - used for exporting and importing BIM data with CSV
- ifcclash - a frontend of FCL, allowing you to trigger clash sets for collision detection
You can launch an interactive Python shell letting you query BIM data in real-time. To do so:
- Install the BlenderBIM Add-on and ensure it is enabled
- Switch to the Blender Python console mode.
- There is no step 3.
You can now type in
import ifcopenshell and it'll work! Have fun!
Alternatively, you can write a full script from a text file and run it. Instead of switching to the Python console mode, just switch to the Blender text editor mode, and press the
Run Script button in the top right once you've written or loaded a script. You can also press
Alt P as a short cut, but your mouse cursor must be over your code when you press the hotkey.
The Blender text editor has basic line numbers, syntax highlighting, and line wrapping abilities. The output will be to the system console (not to mistake with Blender Python Console). On Mac and Windows, the console may not be visible.
To make it visible on Windows, go click on
Window > Toggle System Console.
On Mac you need to start Blender from terminal with
"/Applications/Blender.app/Contents/MacOS/Blender" -con (path can be different depending on your Blender installation).
If you'd like to access the currently loaded or imported IFC file, there is no need to re-open the file with IfcOpenShell. Instead, you can access it as so:
import blenderbim.tool as tool ifc = tool.Ifc.get()
Please remove this "BlenderBIM_Addon_Documentation" template.