Editing BlenderBIM Add-on/Using the Python console with BlenderBIM Add-on

From Wiki.OSArch

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 6: Line 6:
 
* '''bcfplugin''' - used for querying, writing, and manipulating BCF data and files
 
* '''bcfplugin''' - used for querying, writing, and manipulating BCF data and files
 
* '''fcl''' - used for writing custom logic for clash detection
 
* '''fcl''' - used for writing custom logic for clash detection
* '''OCC''' - used or directly accessing the [[Open_CASCADE|Open CASCADE]] geometry kernel for low-level geometric analysis
+
* '''OCC''' - used or directly accessing the OpenCascade geometry kernel for low-level geometric analysis
 
* '''svgwrite''' - used for writing SVG for construction documentation
 
* '''svgwrite''' - used for writing SVG for construction documentation
 
* '''ifcdiff''' - used for comparing IFC files for changes
 
* '''ifcdiff''' - used for comparing IFC files for changes
Line 18: Line 18:
 
You can launch an interactive Python shell letting you query BIM data in real-time. To do so:
 
You can launch an interactive Python shell letting you query BIM data in real-time. To do so:
  
# [https://blenderbim.org/download.html Install the BlenderBIM Add-on] and ensure it is enabled
+
# [https://blenderbim.org/install-blenderbim.html Install the BlenderBIM Add-on] and ensure it is enabled
 
# Switch to the Blender Python console mode.
 
# Switch to the Blender Python console mode.
 
# There is no step 3.
 
# There is no step 3.
Line 28: Line 28:
 
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 <code>Run Script</code> button in the top right once you've written or loaded a script. You can also press <code>Alt P</code> as a short cut, but your mouse cursor must be over your code when you press the hotkey.
 
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 <code>Run Script</code> button in the top right once you've written or loaded a script. You can also press <code>Alt P</code> 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.  
+
The Blender text editor has basic line numbers, syntax highlighting, and line wrapping abilities. On Mac and Linux, the output will be to the console. On Windows, the console may not be visible. To make it visible, go click on <code>Window > Toggle System Console</code>.
To make it visible on Windows, go click on <code>Window > Toggle System Console</code>.
 
On Mac you need to start Blender from terminal with <code>"/Applications/Blender.app/Contents/MacOS/Blender" -con</code> (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:
 
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:
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
import blenderbim.tool as tool
+
import blenderbim.bim.ifc
ifc = tool.Ifc.get()
+
ifc = blenderbim.bim.ifc.IfcStore().get_file()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
{{BlenderBIM_Add-on_Documentation}}
 
{{BlenderBIM_Add-on_Documentation}}
 
[[Category:Blender]] [[Category:BlenderBIM Add-on]]
 
[[Category:Blender]] [[Category:BlenderBIM Add-on]]

Please note that all contributions to Wiki.OSArch are considered to be released under the Creative Commons Attribution-ShareAlike (see Wiki.OSArch:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)