Bonsai-VSCode (for Blender scripting or Bonsai hacking)
Hi all,
This is a follow up of conversation https://community.osarch.org/discussion/2818/best-nice-or-comfortable-practices-to-setup-a-development-environment-for-bonsaibim#latest.
Please find attached PDF output of a possible quickstart guide.
I believe many people use IfcOpenshell scripts so I have redone the sections 1-7 to get you started for that and 8-14 are geared to people looking to explore the Bonsai sourcecode.
You feedback is welcome!
Thanks!
PS: I will create similar ones for Windows/MacOs once the content is agreed.
Comments
Here attached the Windows version.
Thanks!
I have added another bullet: 6.X BONUS: Editing Bonsai Documentation based on the https://docs.bonsaibim.org/guides/development/writing_docs.html
Thanks!
PS: Trying to get access to a MacOS machine to make that version and then go for a pull request for the three of them
Very cool, just what I needed! Will try this (hopefully) somewhere next week and let you know how it went!
Perfect @jes_r .Your feedback is wellcome! :) I have also added a little note about PATH at the begining.
I attach the files relevant to the doc (remove .txt in their extensions).
Thanks!
I have seen that in Windows, F3 and "restart_blender" function does not restart Blender. I have traced this back to the fact that in VSCode Blender extension I am passing parameters to start (--python-expr ...) so a file is automatically loaded upon start of Blender.

When restart_blender calls os.execv(path, sys.argv) this does not work properly.
As a workarround instead of unsing F3, one can simply exit blender and relaunch it again.
I will contact VScode Blender extension maintainer to see if thay can fix it.
Updated the doc.
Thanks!
I have taken a look to the restart_blender function and proposed a PR Update operator.py so argv parameters in Windows are correctly parsed that solves the issue to relaunch blender with the previous parameters.
Now the problem is that VSCode terminal is detached when the os.execv is invoked. It looks like a "Windows" issue... Trying to get arround that to have a similar behaviour as in Linux.
Regards!
Ok. I raised a question to vscode blender extension and they confirmed that this is a windows terminal issue. I have sent a simple PR (Added StartWinCMD to launch Blender within a windows CMD /k shell) for VSCode Extension that adds a new menu entry Blender: Start in Windows CMD


That launches Blender within a CMD shell so when Blender is restarted, the output still goes to this shell.
Updated the doc.
The PR in Bonsai is already merged :) !
Thanks!
Talking to the VSCode Blender Development addon maintainer it looks they prefer to update Blender:Start to spin a CMD /k shell and there the blender executable. I have filled PR Updated launch to spin CMD in the case of Win32 #226 .
Hopefully it is merged and we can remove the note and have the same workflow in windows and linux.
Thanks!
Ok. After raising this question to blender code developers and VSCode Blender Devleopment extension, it looked that it was Windows handling of the console that was resposible for this behaviour (in Linux there is no such issue).

I have found that VSCode has also a conpty Dll that does not have these issues. By activating it, no need to run blender within a CMD.
VSCode terminal.windows.exec -> Using the experimental conpty Dll from VSCode
The doc is updated to turn this on in the case of Windows
Thanks!
@falken10vdl thanks for your work on this, it is really valuable to have simple and in-depth guidance for those of us (read: me) who struggle with setting up all the boiler-plate stuff before getting into the meat of "development".
Stupid question - are these docs hosted online? In here somewhere??? https://docs.ifcopenshell.org/index.html
@CSN Not yet. I have created the documentation as to be included. Just wanted to have people's feedback before creating a Pull Request to the project to get it included under quickstarts or guides I guess.

Please find attached the print for Windows & Linux. For Mac I need to get access to one so it will take som more time.
@Moult , let me know if I can send a PR for it.
Thanks!
@falken10vdl this is absolutely fantastic and very timely for me. I read the Windows IDE version and noted a few typo errors. See attached.
Thanks @Rick_Brice ! for the feedback. Please if something should be rephrased fir better understanding, let me know. I am not a native English speaker.
Thanks!
my vote would be to just PR it, so others can comment with github tools, etc.
on a high level, looks great, btw.
Yeah, I noticed some oddities with the Linux instructions. Pain to explain here, whereas, pretty easy to do so in github where comments are tracked.
@theoryshaw Here you go. PR: Added Quickstart guides for Linux and Windows IDEs using VSCode #6494
Thanks!
@sjb007 Thanks for reviewing it! Probably should also be updated for debian/ubuntu distributions.
Thanks!