All Projects → AlansCodeLog → Blender Debugger For Vscode

AlansCodeLog / Blender Debugger For Vscode

Licence: gpl-3.0
Blender addon for remote debugging Blender with VS Code (and Visual Studio)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Blender Debugger For Vscode

Android Debug Database
A library for debugging android databases and shared preferences - Make Debugging Great Again
Stars: ✭ 7,946 (+6360.16%)
Mutual labels:  debugging, debug
Debugdrawer
Android Debug Drawer for faster development
Stars: ✭ 1,168 (+849.59%)
Mutual labels:  debugging, debug
Bugsnag Node
[DEPRECATED] Please upgrade to our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 48 (-60.98%)
Mutual labels:  debugging, debug
Blender Iks To Fks
A Blender script that takes a mesh and armature that use IKs and other non-deformation bones and creates a new mesh and armature that uses only FK bones.
Stars: ✭ 34 (-72.36%)
Mutual labels:  blender, blender-addon
React Native Logs
Performance-aware simple logger for React-Native with namespaces, custom levels and custom transports (colored console, file writing, etc.)
Stars: ✭ 84 (-31.71%)
Mutual labels:  debugging, debug
Create Isocam
Create ISO Camera addon for Blender 2.8+
Stars: ✭ 37 (-69.92%)
Mutual labels:  blender, blender-addon
Vscode Ts Webpack Node Debug Example
VSCode TypeScript Webpack Node Debug Example
Stars: ✭ 66 (-46.34%)
Mutual labels:  vscode, debugging
Node In Debugging
《Node.js 调试指南》
Stars: ✭ 6,139 (+4891.06%)
Mutual labels:  debugging, debug
Vlog
An in-display logging library for Android 📲
Stars: ✭ 86 (-30.08%)
Mutual labels:  debugging, debug
Meshroom2blender
Blender importer of meshroom datafiles: cameras, images, sparse pointcloud and obj's.
Stars: ✭ 82 (-33.33%)
Mutual labels:  blender, blender-addon
Unitydbgdraw
DbgDraw is an API that provides the ability to render various 2D and 3D shapes for visual debugging purposes.
Stars: ✭ 20 (-83.74%)
Mutual labels:  debugging, debug
Scala Trace Debug
Macro based print debugging. Locates log statements in your IDE.
Stars: ✭ 110 (-10.57%)
Mutual labels:  debugging, debug
Bugsnag Laravel
Bugsnag notifier for the Laravel PHP framework. Monitor and report Laravel errors.
Stars: ✭ 746 (+506.5%)
Mutual labels:  debugging, debug
Bugsnag Android
Bugsnag crash monitoring and reporting tool for Android apps
Stars: ✭ 990 (+704.88%)
Mutual labels:  debugging, debug
Mixer
Add-on for real-time collaboration in Blender (mirror only, please post your issues and merge requests at https://gitlab.com/ubisoft-animation-studio/mixer)
Stars: ✭ 718 (+483.74%)
Mutual labels:  blender, blender-addon
Mb Lab
MB-Lab is a character creation tool for Blender 2.80+, based off ManuelBastioniLAB
Stars: ✭ 1,078 (+776.42%)
Mutual labels:  blender, blender-addon
Awesome Blender
🪐 A curated list of awesome Blender addons, tools, tutorials; and 3D resources for everyone.
Stars: ✭ 608 (+394.31%)
Mutual labels:  blender, blender-addon
Building tools
Building generation addon for blender
Stars: ✭ 692 (+462.6%)
Mutual labels:  blender, blender-addon
Blenderdatavis
Data visualisation addon for Blender
Stars: ✭ 72 (-41.46%)
Mutual labels:  blender, blender-addon
Debug
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers
Stars: ✭ 9,912 (+7958.54%)
Mutual labels:  debugging, debug

Blender Debugger for VS Code (and Visual Studio)

Inspired by Blender-VScode-Debugger which was itself inspired by this remote_debugger for pycharm as explained in this Blender Developer's Blog post.

Since the VS Code one wasn't really well documented and it looked kind of dead, once I figured it out, I was just going to add the documentation, but then I ended up rewriting the whole thing.

Now it can:

  • Auto-detect where python is and auto set the path to ptvsd if installed.
  • Warn you if you installed the wrong ptvsd version (for VS Code, for Visual Studio it should still work)
  • Tell you when the debugger has actually attached.

Image Showing VS Code side by side with Blender paused at a breakpoint. In the console, a "Debugger is Attached" Statement is printed. Note: This video is now a bit old, it was made with Blender 2.79. If you are using the current version of Blender, some minor things have changed, but the general usage is still the same.

How to Use

I have made a video (click the image below) for those who just started messing with python in Blender or programming in general, but if you're semi-familiar with Python, VS Code, and the command line the following should make sense. If you have any questions or suggestions, don't hesitate to file an issue.

NOTES/EDITS

  • ptvsd doesn't have to be version 3.0.0 anymore, so you can now ignore that and just pip install ptvsd
  • This video was done with blender 2.79, but everything still works 99% the same. I think the only change is that blender changed the default shortcut to the search menu.

youtube video

Note on Downloading

The best way to download is through the green Clone or Download button above.

If you download the add-on from the releases page, please make sure to rename the zip to blender-debugger-for-vscode-master.zip, otherwise the full stops / periods in the version number will cause the add-on to silently fail installing.

Installing Python and Getting PTVSD

Install Python 3 with pip and check add to PATH.1

  • If you already have python installed and you can run it from the command line (aka PATH is set), the addon should find it. It checks where python or whereis python or which python to try and determine where python is and uses the first path given2.
  • If you are using something like Conda and want to use a virtual environment, to have the addon auto-detect the path you can: activate the environment, run Blender from the command line, and it should work.

pip install ptvsd

  • For Visual Studio, the ptvsd version that works depends on the Visual Studio version. I have never used Visual Studio, but you can find more info on setting everything up here: Remotely Debugging Python Code on Linux. (it is not Linux specific)

Setting up your Addon

This is the most important part. Otherwise it won't work. I thought it was my VS Code config but no, it was this.

In Blender go to: User Preferences > File and set the path to Scripts to the folder you're developing your addon in (e.g: "C:\Code\Blender Stuff") BUT the folder must look like this:

Blender Stuff
└── addons
	├── your-addon-folder
		├── __init__.py
		├── ...etc
	├── another-addon
	├── ...

Now remove your addon from Blender if you had installed it manually already, save settings, and when you restart your addon should be installed automatically.

Setting up this Addon

Install the addon.

If it did not find the path it'll say "PTVSD not Found", you'll have to set it manually. It's wherever python is + "\lib\site-packages". NO trailing backslash.

If you want, increase the timeout for the confirmation. It'll print "Waiting..." in the console every second until it prints it's timedout. This does not mean the server has timedout just the confirmation listener.

If you're using Blender 2.9 you must turn on Developer Extras (Preferences => Display => Developer Extras) if you haven't already, otherwise the addon's commands won't turn up in the search.

Open up Blender's search (default shortcut: F3), type "Debug".

Click Debug: Start Debug Server for VS Code.

Note: you can only start the server once. You cannot stop it, at least from what I understand. If you run it again it'll just tell you it's already running and start the timer again to check for a confirmation.

Connecting the Editor

Open your addon folder (e.g. "C:\Code\Blender Stuff\addons\myaddon").

Install the Python extension for VS Code if you haven't already. For Visual Studio see Installing Python Support.

In the lower left (see #3 here), VS Code should have auto detected your Python install and set it as the interpreter. For Visual Studio see Managing Python Environments.

Go to the Debugging tab and add a configuration. Pick Python. You'll want the configuration that looks like this, no need to change the defaults, you can delete the rest.

	{
		"name": "Python: Attach",
		"type": "python",
		"request": "attach",
		"port": 5678, //careful, this used to be 3000 in older versions of vscode and this addon
		"host": "localhost"
	},

Now when you run the debugger with this config in Blender and VS Code the console should print "Debugger is Attached" if it was still waiting (it should still attach even if it wasn't, it just won't tell you).

How to Use

At this point you should be able to add a breakpoint and when you trigger it in Blender, Blender should freeze and VS Code should pause on the breakpoint.

Note though that if you make changes to the file, Blender will not detect them. Have open User Preferences > Addons so you can toggle your addon on and off when you make changes. If anyone knows any way to improve this I'd love to know.

Debugging/Editing Source Code

It is possible to edit the Blender source code but it can be a bit tricky to get it to detect changes (nevermind live editing is buggy anyways).

From blender you can right click just about anything and click "Edit Source" to get it in the text editor. Then to find the path of the file, go to Text > Save As and copy it from there.

Open the file in VS Code, connect to the debugging server, make a change and save it.

Now in Blender the text editor will show this little red button in the top left. Click that and reload the file. Then in Text Editor > Properties turn on Live Edit if you haven't already. Now to actually get Blender to detect any changes you made just type a single character (like add a space anywhere) and then it will detect your changes.

Debugging/Editing Scripts

See [Issue #4](https://github.com/AlansCodeLog/blender-debugger-for-vscode/issues/4) for a workaround.
In the future if I have some time, I might see if there's something I can do to make this easier.

Troubleshooting

  • Check you installed the correct ptvsd version. With VS Code this should no longer be an issue, but I believe different versions of Visual Studio need different versions of ptvsd (see Installing Python Support).
  • To determine whether the problem is on Blender's side or your editor's: Close Blender and download/copy this test script and run it with Python, and then try to connect to the server with your editor. If you're still getting problems then the problem is with VS Code, try: - Check your detected your Python install, or set it manually. - For VS Code try reinstalling the VS Code Python extension.
  • If you've been using this addon for a while and it's suddenly giving you a connection error, it might be because the default port has changed. VS Code's Python extension (vscode-python) has changed their default port from 3000 to 5678, so I have changed the default accordingly. I've made it configurable now though, so just check the port the addon is set to matches the one in your launch.json in VS Code.

Otherwise, if none of that helped, don't hesitate to file an issue.

Notes

1. Technically, the add-on will work with Python 2 as well since it doesn't use Python itself, just the ptvsd package, so it doesn't really matter whether you installed it with Python 2 or 3 because the package is compatible with both. On the VS Code side though, the Python extension does need to know where Python is (though not ptvsd), but it will still connect if it's using Python 2, but your IntelliSense recommendations will be wrong in VS Code.

2. The addon also detects python if PYTHONPATH is set (because Blender will add it to sys.path) or if you used the Python bundled with Blender to install ptvsd (but that's a bit of a pain because it doesn't have pip installed, you would have to install it manually).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].