### Setup Development Environment (Linux/Mac) Source: https://docs.bonsaibim.org/guides/development/installation.html Run this script to set up the development environment on Linux or Mac. It replaces installed Python files with those from the Git repository using symbolic links. ```bash cd src/bonsai/scripts python dev_environment.py ``` -------------------------------- ### Install Documentation Dependencies Source: https://docs.bonsaibim.org/guides/development/writing_docs.html Install the necessary theme and dependencies for building the documentation locally using pip. ```bash pip install furo pip install sphinx-autoapi pip install sphinx-copybutton ``` -------------------------------- ### Install pytest Source: https://docs.bonsaibim.org/guides/development/running_tests.html Install the pytest framework using pip. This is a prerequisite for running any Bonsai tests. ```bash pip install pytest ``` -------------------------------- ### Manual Installation File Names Source: https://docs.bonsaibim.org/guides/development/installation.html These are the file names for manually downloading and installing BonsaiPR, specific to different platforms and architectures. ```text bonsaiPR_py311-0.8.4-alphaYYMMDDHHMM-linux-x64.zip ``` ```text bonsaiPR_py311-0.8.4-alphaYYMMDDHHMM-macos-x64.zip ``` ```text bonsaiPR_py311-0.8.4-alphaYYMMDDHHMM-macos-arm64.zip ``` ```text bonsaiPR_py311-0.8.4-alphaYYMMDDHHMM-windows-x64.zip ``` -------------------------------- ### Install Sphinx and Dependencies Source: https://docs.bonsaibim.org/guides/development/ide/windows_ide.html Installs Sphinx, a documentation generator, along with the Furo theme and necessary Sphinx extensions for the project. These commands should be run in the VSCode terminal. ```bash choco install sphinx python3.11 -m pip install furo python3.11 -m pip install sphinx-autoapi python3.11 -m pip install sphinx-copybutton ``` -------------------------------- ### Build Documentation Locally Source: https://docs.bonsaibim.org/guides/development/writing_docs.html Commands to navigate to the documentation directory, build the HTML documentation, and start a local HTTP server. ```bash cd /path/to/ifcopenshell/src/bonsai/docs/ make html cd _build/html python -m http.server ``` -------------------------------- ### Install Sphinx and Theme Dependencies Source: https://docs.bonsaibim.org/guides/development/ide/linux_ide.html Commands to install Sphinx, a documentation generator, along with the 'furo' theme and 'sphinx-autoapi', 'sphinx-copybutton' extensions for enhanced documentation building. These are typically run in a terminal. ```bash yum install python-sphinx ``` ```bash python3.11 -m pip install furo ``` ```bash python3.11 -m pip install sphinx-autoapi ``` ```bash python3.11 -m pip install sphinx-copybutton ``` -------------------------------- ### Install Visual Studio Code on Linux Source: https://docs.bonsaibim.org/guides/development/ide/linux_ide.html Adds the VSCode repository, imports the GPG key, and installs VSCode using the dnf package manager. ```bash sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc echo -e "[code] name=Visual Studio Code baseurl=https://packages.microsoft.com/yumrepos/vscode enabled=1 autorefresh=1 type=rpm-md gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null dnf check-update sudo dnf install code # or code-insiders ``` -------------------------------- ### Inline and Block Code Examples Source: https://docs.bonsaibim.org/guides/development/writing_docs.html Use inline code formatting for short code snippets and code blocks for longer examples. Specify the language for syntax highlighting. ```bash cd /path/to/bonsai ls ``` ```python print("Hello, world!") ``` -------------------------------- ### Local Server Running Message Source: https://docs.bonsaibim.org/guides/development/writing_docs.html Example output when the local webserver for documentation is running. It indicates the host and port. ```text Serving HTTP on :: port 8000 (http://[::]:8000/) ... ``` -------------------------------- ### Blender Add-on Installation Path (Zip File) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This path is used when Blender is installed from a .zip file without running an installer. Replace X.XX with your Blender version. ```bash /path/to/blender/X.XX/ ``` -------------------------------- ### Blender Add-on Installation Path (Windows) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This is the default path for add-on installations on Windows. Replace {YOUR_USER} with your username and X.XX with your Blender version. ```bash C:\Users\{YOUR_USER}\AppData\Roaming\Blender Foundation\X.XX\ ``` -------------------------------- ### Install fake-bpy-module Source: https://docs.bonsaibim.org/guides/development/ide/windows_ide.html Installs the 'fake-bpy-module' for VSCode autocompletion and features. Run this command in the VSCode terminal. ```bash python3.11 -m pip install fake-bpy-module-latest ``` -------------------------------- ### Install VSCodium via Snap Source: https://docs.bonsaibim.org/guides/development/debugging.html Use this command to install VSCodium, an alternative to VSCode that avoids Microsoft telemetry. ```bash sudo snap install --classic codium ``` -------------------------------- ### Install Specific Python Version on Linux Source: https://docs.bonsaibim.org/guides/development/ide/linux_ide.html Downloads, configures, and installs a specific Python version (e.g., 3.11.11) using 'altinstall' to avoid conflicts with the system's default Python. Requires development tools. ```bash wget https://www.python.org/ftp/python/3.11.11/Python-3.11.11.tgz tar -xvf Python-3.11.11.tgz cd Python-3.11.11 sudo dnf install gcc openssl-devel bzip2-devel libffi-devel ./configure --enable-optimizations nproc make -j 4 #adjust the value to the one provided by nproc sudo make altinstall ``` -------------------------------- ### Set Breakpoint Example Source: https://docs.bonsaibim.org/guides/development/debugging.html An example of setting a breakpoint in the `bim.add_sheet` operator. Note that setting the breakpoint on the `def` line of the `_execute` method may not work. ```python extensions/.local/lib/python3.11/site-packages/bonsai/bim/module/drawing/operator.py:1456 ``` -------------------------------- ### Download and Install Blender on Linux Source: https://docs.bonsaibim.org/guides/development/ide/linux_ide.html Download, extract, and move the Blender 4.2 LTS archive to the user's local share directory. Ensure the bin directory exists. ```bash wget https://download.blender.org/release/Blender4.2/blender-4.2.8-linux-x64.tar.xz tar -xvf blender-4.2.8-linux-x64.tar.xz mv blender-4.2.8-linux-x64 /home/falken10vdl/.local/share/applications/blender-4.2.8-linux-x64 ``` -------------------------------- ### Add Remote Repository for Unstable Installation Source: https://docs.bonsaibim.org/guides/development/installation.html Manually add the unstable Bonsai repository using the provided URL. Enable 'Check for Updates on Startup' for automatic daily updates. ```text https://raw.githubusercontent.com/IfcOpenShell/bonsai_unstable_repo/main/index.json ``` -------------------------------- ### C++ Code Style Example Source: https://docs.bonsaibim.org/guides/development/code_style.html This C++ code snippet demonstrates the recommended style, including header guards, class structure, and brace placement. ```cpp #ifndef FOO_H #define FOO_H class foo { public: void bar(bool foo_or_bar) { if (foo_or_bar) { // ... } else { // ... } } private: bool i_am_foo_; } #endif ``` -------------------------------- ### Configure Development Environment Paths Source: https://docs.bonsaibim.org/guides/development/ide/windows_ide.html Edit this batch script to match your local system paths for the IfcOpenShell repository, Blender installation, and Bonsai addon. ```batch SET REPO_PATH=%HOMEDRIVE%\Users\%USERNAME%\Documents\bonsaiDevel\IfcOpenShell SET BLENDER_PATH=%HOMEDRIVE%\Users\%USERNAME%\AppData\Roaming\Blender Foundation\Blender\4.2 SET PACKAGE_PATH=%BLENDER_PATH%\extensions\.local\lib\python3.11\site-packages SET BONSAI_PATH=%BLENDER_PATH%\extensions\raw_githubusercontent_com\bonsai ``` -------------------------------- ### VSCode Debug Configuration Source: https://docs.bonsaibim.org/guides/development/ide/windows_ide.html Example VSCode configuration files for debugging and building documentation. Ensure paths are updated for your system. ```json { "version": "0.2.0", "configurations": [ { "name": "BonsaiDocsServer (IfcOpenShell)", "type": "python", "request": "launch", "program": "${workspaceFolder}/docs/make.py", "args": [ "html", "-o", "${workspaceFolder}/build/docs", "${workspaceFolder}/docs" ], "console": "integratedTerminal", "justMyCode": false } ] } ``` ```json { "version": "2.0.0", "tasks": [ { "label": "Build Docs", "type": "shell", "command": "python3.11 -m sphinx -b html docs build/docs", "group": { "kind": "build", "isDefault": true }, "presentation": { "reveal": "always", "panel": "new" }, "problemMatcher": [] } ] } ``` -------------------------------- ### Set Blender Binary Path Source: https://docs.bonsaibim.org/guides/development/debugging.html When prompted by the Blender addon, provide the correct path to your Blender binary. Do not use a binary installed via snap; use a Debian package or a custom build. ```bash /home/steve/Software/blender-git/build_linux/bin/blender ``` -------------------------------- ### Blender Add-on Installation Path (Mac User Install) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This is the default path for user-specific add-on installations on macOS. Replace X.XX with your Blender version. ```bash /Users/{YOUR_USER}/Library/Application Support/Blender/X.XX/ ``` -------------------------------- ### Blender Add-on Installation Path (Linux User Install) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This is the default path for user-specific add-on installations on Linux. Replace X.XX with your Blender version. ```bash ~/.config/blender/X.XX/ ``` -------------------------------- ### Bonsai Demo Module Files Source: https://docs.bonsaibim.org/guides/development/hello_world.html List of files associated with the Bonsai 'hello world' demo module. These files contain tutorial comments to guide developers through Blender's add-on system, interfaces, and Bonsai's architecture. ```text src/bonsai/bonsai/bim/module/demo/__init__.py src/bonsai/bonsai/bim/module/demo/operator.py src/bonsai/bonsai/bim/module/demo/prop.py src/bonsai/bonsai/bim/module/demo/ui.py src/bonsai/bonsai/bim/module/demo/data.py src/bonsai/bonsai/core/demo.py src/bonsai/bonsai/tool/demo.py ``` -------------------------------- ### Install pytest-blender Source: https://docs.bonsaibim.org/guides/development/running_tests.html Install the pytest-blender plugin, which is necessary for running tool and UI tests that interact with Blender. ```bash pip install pytest-blender # Check that "Blender" is in your system's path blender ``` -------------------------------- ### VS Code Launch Configuration for Debugging Docs Server Source: https://docs.bonsaibim.org/guides/development/writing_docs.html Set up a VS Code launch configuration to run the documentation server. It uses a pre-launch task to build the docs and then starts the Python HTTP server for debugging. ```json { "version": "0.2.0", "configurations": [ { "name": "BonsaiDocsServer", "type": "python", "request": "launch", "program": "D:/ifcopenshell/src/bonsai/docs/_build/html", "args": ["-m", "http.server"], "preLaunchTask": "Build and Serve Docs", "console": "integratedTerminal" } ] } ``` -------------------------------- ### Install Black Code Formatter Source: https://docs.bonsaibim.org/guides/development/ide/linux_ide.html Install the Black code formatter using pip. This tool is used to format Python code. ```bash python3.11 -m pip install black ``` -------------------------------- ### Blender Add-on Installation Path (Mac System-wide Install) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This path is used for system-wide add-on deployments on macOS. Replace X.XX with your Blender version. ```bash /Library/Application Support/Blender/X.XX/ ``` -------------------------------- ### Build Blender Add-on with Makefile Source: https://docs.bonsaibim.org/guides/development/installation.html Use the Makefile to create a packaged Blender add-on from the Bonsai source code. Specify the desired PLATFORM and PYVERSION. ```bash cd src/bonsai make dist PLATFORM=linux PYVERSION=py311 ls dist/ ``` -------------------------------- ### Prepare IfcTester Webapp Source: https://docs.bonsaibim.org/guides/development/installation.html Use this command to prepare the IfcTester webapp. Ensure you are in the src/ifctester directory. ```bash cd src/ifctester make webapp-prepare ``` -------------------------------- ### Bonsai Demo Module Tests Source: https://docs.bonsaibim.org/guides/development/hello_world.html Location of test files for the Bonsai 'hello world' demo module. These tests are part of the system's Test Driven Development (TDD) approach. ```text src/bonsai/test/bim/feature/demo.feature src/bonsai/test/core/test_demo.py src/bonsai/test/tool/test_demo.py ``` -------------------------------- ### Blender Add-on Installation Path (Linux System-wide Install) Source: https://docs.bonsaibim.org/guides/troubleshooting.html This path is used for system-wide add-on deployments on Linux. The exact location may vary by distribution. Replace X.XX with your Blender version. ```bash /usr/share/blender/X.XX/ ``` -------------------------------- ### CSV Alignment Definition Example Source: https://docs.bonsaibim.org/guides/alignment.html This example demonstrates the expected format for a CSV file defining a horizontal and vertical alignment using the PI method. R1 and Rn, as well as L1 and Ln, should be set to 0.0. The CSV must contain at least three horizontal points. ```csv 500,2500,0.0,3340,660,1000,4340,5000,1250,7600,4560,950,8480,2010,0 0,100,0,2000,135,1600,5000,105,1200,7400,153,2000,9800,105,800,12800,90,0 ```