|
1 | 1 | Debugging Bonsai |
2 | 2 | ================ |
3 | 3 |
|
4 | | -This is a mini-guide to setting up an IDE and configuring it to debug Bonsai more |
5 | | -easily. It is currently specific to this writers own system (Ubuntu) but this |
6 | | -can be expanded by others. |
| 4 | +This is a mini-guide to setting up an IDE and configuring it to debug Bonsai |
| 5 | +more easily. It is currently specific to this writers own system (Ubuntu) but |
| 6 | +this can be expanded by others. |
7 | 7 |
|
8 | | -1. **Install VSCodium**: This will be system specific. I used the available |
9 | | - snap package. |
| 8 | +1. **Install VSCode/VSCodium**: This will be system specific. I used the |
| 9 | + available snap package. |
10 | 10 |
|
11 | 11 | .. code-block:: bash |
12 | 12 |
|
13 | | - sudo snap install --classic codium |
| 13 | + sudo snap install --classic codium |
14 | 14 |
|
15 | 15 | I chose VSCodium to avoid Microsoft telemetry and data harvesting, but |
16 | | - VSCode is going to be similar, and even a bit easier (i.e. steps 3 & 4). |
| 16 | + VSCode is going to be similar, and even a bit easier (i.e. step 3). |
17 | 17 |
|
18 | | -2. **Activate Python language support**: Start VSCodium, open the Extensions, find the Python |
19 | | - language support and activate it. |
| 18 | +2. **Activate Python language support**: Start VSCode/VSCodium, open the |
| 19 | + Extensions tab, find the Python language support and activate it. |
20 | 20 |
|
21 | | -3. **Install Blender Addon**: It seems VSCodium is not allowed to directly access |
22 | | - the Marketplace, and this addon (and the next) is not available in |
23 | | - VSCodium's equivalent. (Or I'm an idiot... entirely possible). This means a |
24 | | - few more steps are needed. |
| 21 | +3. **Install Blender Addon**: This step depends on which IDE you chose. |
25 | 22 |
|
26 | | - Download the Blender addon's ``.vsix`` file from marketplace (Under "Resources") |
27 | | - using your browser from `this <https://marketplace.visualstudio.com/items?itemName=JacquesLucke.blender-development>`_ |
28 | | - page. |
| 23 | + a. VSCode |
29 | 24 |
|
30 | | - Install it with "**...**" -> "**Install from VSIX...**" |
| 25 | + Open up the Extensions tab on the left, and search for the *Blender |
| 26 | + Development* extension. Select it, and click Install. |
31 | 27 |
|
32 | | -4. **Install ms-vscode.cpptools**: When trying to use the Blender addon I got |
33 | | - an error about a missing dependancy. I read somewhere that this addon was |
34 | | - not needed, but I can't currently find the reference. At least for me, it |
35 | | - needs to be added the same way as step 3, or the Blender addon fails to |
36 | | - start. |
| 28 | + I haven't actually tested this, but this should install the |
| 29 | + *ms-vscode.cpptools* dependancy for you. If not, you may need to search |
| 30 | + for, and install, this extension too. |
37 | 31 |
|
38 | | - Download the Cpp Tools addon's ``.vsix`` file from marketplace (Under "Resources") |
39 | | - using your browser from `this <https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools>`_ |
40 | | - page. You will need to select the correct download for your system OS and |
41 | | - architecture. |
| 32 | + b. VSCodium |
42 | 33 |
|
43 | | - Install it with "**...**" -> "**Install from VSIX...**" |
| 34 | + It seems VSCodium is not allowed to direct access the Marketplace, and |
| 35 | + due to licensing it is not possible to install the *Blender Development* |
| 36 | + extension because of the *ms-vscode.cpptools* dependancy. |
44 | 37 |
|
45 | | -5. **Set the Blender config directory**: In **Settings** -> **Extensions** -> **Blender** -> "**Environment Variables**" |
| 38 | + VSCodium's equivalent Marketplace does not (and could not due to |
| 39 | + licensing) provide a functioning *Blender Development* extension. (Or I'm |
| 40 | + an idiot... entirely possible). |
| 41 | + |
| 42 | + I've created an alternative *Blender Development* extension with the |
| 43 | + *ms-vscode.cpptools* dependancy removed. |
| 44 | + |
| 45 | + .. note:: |
| 46 | + This alternative should also work in VSCode, but you may as well save |
| 47 | + yourself the hassle, and just use the original one. |
| 48 | + |
| 49 | + Download the *Blender Development* ``.vsix`` file from my GitHub fork |
| 50 | + using your browser from `this <https://github.com/sboddy/blender_vscode>`_ |
| 51 | + repository. The ``.vsix`` is available on the Releases page. |
| 52 | + |
| 53 | + In VSCodium's Extensions sidebar install it with "**...**" -> |
| 54 | + "**Install from VSIX...**" |
| 55 | + |
| 56 | + If you are squeamish about downloading my ``.vsix``, you can review the |
| 57 | + single commit, clone the repo and create your own. |
| 58 | + |
| 59 | +4. **Set the Blender config directory**: In **Settings** -> **Extensions** -> |
| 60 | + **Blender** -> "**Environment Variables**" |
46 | 61 | edit the json file to set the ``BLENDER_USER_RESOURCE`` to the config folder |
47 | | - you installed Bonsai to. For me: |
| 62 | + you installed Bonsai to. *For me*: |
48 | 63 |
|
49 | 64 | .. code-block:: json |
50 | 65 |
|
51 | | - { |
52 | | - "blender.environmentVariables": { |
53 | | - "BLENDER_USER_RESOURCES": "/home/steve/.config/blender/4.2bonsai" |
54 | | - } |
55 | | - } |
| 66 | + { |
| 67 | + "blender.environmentVariables": { |
| 68 | + "BLENDER_USER_RESOURCES": "/home/steve/.config/blender/4.2bonsai" |
| 69 | + } |
| 70 | + } |
56 | 71 |
|
57 | | - .. note:: |
58 | | - You `must` change that path to the correct value for your system. |
| 72 | + .. warning:: |
| 73 | + You `must` change that path to the correct value for your system. |
59 | 74 |
|
60 | | -6. **Unset the Just My Code flag**: In **Settings** -> **Extensions** -> **Blender** -> "**Just My Code**" |
61 | | - by unchecking the box. |
| 75 | +5. **Unset the Just My Code flag**: In **Settings** -> **Extensions** -> |
| 76 | + **Blender** -> "**Just My Code**" by unchecking the box. |
62 | 77 |
|
63 | 78 | Again, this was advice found searching around in a github issue. If not |
64 | 79 | done, the breakpoints do not work for me. |
65 | 80 |
|
66 | | -7. **Open the folder in VSCodium**: This is the same folder set in step 5. |
| 81 | +6. **Open the folder in VSCode/VSCodium**: This is the same folder set in step |
| 82 | + 5. Again, *for me*: |
67 | 83 |
|
68 | 84 | ``/home/steve/.config/blender/4.2bonsai`` |
69 | 85 |
|
70 | 86 | This was a key point for me. Do `not` go deeper in the folder structure - |
71 | | - that just doesn't work. (Thanks @theoryshaw) |
| 87 | + that just doesn't work. (Thanks @theoryshaw) This feels a little like |
| 88 | + using a sledgehammer to crack a nut, and there might be a better, "proper" |
| 89 | + way of setting this up. If there is I'd love to hear it. |
72 | 90 |
|
73 | | -8. **Start Blender**: In VSCodium press ``Ctrl+Shift+P``, and search/select |
74 | | - **Blender: Start**. |
| 91 | +7. **Start Blender**: In VSCode/VSCodium press ``Ctrl+Shift+P``, and |
| 92 | + search/select **Blender: Start**. |
75 | 93 |
|
76 | | -9. **Set the Blender binary path**: The first time you try to start Blender the |
| 94 | +8. **Set the Blender binary path**: The first time you try to start Blender the |
77 | 95 | addon will ask for the path of the binary. Navigate to your Blender binary |
78 | | - and select it. For me: |
| 96 | + and select it. *For me*: |
79 | 97 |
|
80 | 98 | ``/home/steve/Software/blender-git/build_linux/bin/blender`` |
81 | 99 |
|
82 | 100 | .. warning:: |
83 | | - Do `not` try to use a binary installed using snap - it will `not` work. |
84 | | - Either install a debian package of Blender, or build it from source, and |
85 | | - use that. |
| 101 | + Do `not` try to use a binary installed using snap - it will `not` work. |
| 102 | + Either install a debian package of Blender, or build it from source, and |
| 103 | + use that. |
86 | 104 |
|
87 | 105 | All being well, Blender should start and show the usual Bonsai UI. |
88 | 106 |
|
89 | | -10. **Ensure Blender is behaving**: Exercise the interface a bit to be sure |
90 | | - Bonsai is working normally. Add a demo project, add some walls, etc. |
| 107 | +9. **Ensure Blender is behaving**: Exercise the interface a bit to be sure |
| 108 | + Bonsai is working normally. Add a demo project, add some walls, etc. |
91 | 109 |
|
92 | | - One issue I ran in to was opening the wrong folder in step 7. Due to the |
93 | | - way VSCodium works, I was getting two Bonsai plugins conflicting, and |
94 | | - failing in interesting ways. One symptom of this was the modal user |
95 | | - interface when adding walls was completely missing. Oh, and the debugger |
96 | | - completely failed to work. |
| 110 | + One issue I ran in to was opening the wrong folder in step 7. Due to the |
| 111 | + way VSCode/VSCodium works, I was getting two Bonsai plugins conflicting, |
| 112 | + and failing in interesting ways. One symptom of this was the modal user |
| 113 | + interface when adding walls was completely missing. Oh, and the debugger |
| 114 | + completely failed to work. |
97 | 115 |
|
98 | | - If you are happy, quit Blender, and try setting some breakpoints in |
99 | | - VSCodium then run Blender again, and try to trigger them. I set one on |
100 | | - the ``bim.add_sheet`` operator at: |
101 | | - ``extensions/.local/lib/python3.11/site-packages/bonsai/bim/module/drawing/operator.py:1456`` |
| 116 | + If you are happy, quit Blender, and try setting some breakpoints in |
| 117 | + VSCode/VSCodium then run Blender again, and try to trigger them. I set one |
| 118 | + on the ``bim.add_sheet`` operator at: |
| 119 | + ``extensions/.local/lib/python3.11/site-packages/bonsai/bim/module/drawing/operator.py:1456`` |
102 | 120 |
|
103 | | - .. note:: |
104 | | - I made the mistake of setting the breakpoint on the ``_execute`` |
105 | | - methods ``def`` line, which did not work. This probably helped confuse |
106 | | - me when trying to get the addon to work. |
| 121 | + .. note:: |
| 122 | + I made the mistake of setting the breakpoint on the ``_execute`` |
| 123 | + methods ``def`` line, which did not work. This probably helped confuse |
| 124 | + me when trying to get the addon to work. |
107 | 125 |
|
108 | 126 | If you get to this point, congratulations! You will now be 1000% more effective |
109 | 127 | when troubleshooting issues, and able to make many more contributions, fixes |
|
0 commit comments