You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-18Lines changed: 28 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ Now it can:
12
12
13
13
# How to Use
14
14
15
-
I'm in the process of writing a more detailed blog post 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.
15
+
I'm in the process of writing a more detailed blog post 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.
16
16
17
17
## Installing Python and Getting PTVSD
18
18
19
19
Install Python 3 with pip and check add to PATH.
20
-
- 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 uses `where python` or `whereis python` or `which python` depending on the OS to determine where python is. I only have windows at the moment, so only that is tested, but it should work.
20
+
- 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 uses `where python` or `whereis python` or `which python` depending on the OS to determine where python is. I only have windows at the moment, so only that is tested, but it should work.
21
21
22
22
`pip install ptvsd==3.0.0"
23
-
- 3.0 because that was what was recommended in the VS Code documentation.
23
+
- 3.0 because that was what was recommended in the VS Code documentation.
24
24
25
25
## Setting up your Addon
26
26
@@ -31,11 +31,11 @@ In Blender go to: `User Preferences > File` and set the path to `Scripts` to the
31
31
```
32
32
Blender Stuff
33
33
└── addons
34
-
├── your-addon-folder
35
-
├── __init__.py
36
-
├── ...etc
37
-
├── another-addon
38
-
├── ...
34
+
├── your-addon-folder
35
+
├── __init__.py
36
+
├── ...etc
37
+
├── another-addon
38
+
├── ...
39
39
```
40
40
41
41
Now remove your addon from Blender if it was installed, save settings, and when you restart your addon should be installed automatically.
@@ -61,16 +61,16 @@ Install the Python extension for VS Code if you haven't already.
61
61
Go to the Debugging tab and add a configuration. Pick Python. You'll want the configuration that looks like this, you can delete the rest. There's no need to change the defaults.
62
62
63
63
```JSON
64
-
{
65
-
"name": "Python: Attach",
66
-
"type": "python",
67
-
"request": "attach",
68
-
"localRoot": "${workspaceFolder}",
69
-
"remoteRoot": "${workspaceFolder}",
70
-
"port": 3000,
71
-
"secret": "my_secret",
72
-
"host": "localhost"
73
-
},
64
+
{
65
+
"name": "Python: Attach",
66
+
"type": "python",
67
+
"request": "attach",
68
+
"localRoot": "${workspaceFolder}",
69
+
"remoteRoot": "${workspaceFolder}",
70
+
"port": 3000,
71
+
"secret": "my_secret",
72
+
"host": "localhost"
73
+
},
74
74
```
75
75
76
76
Now when you run the debugger with this config in Blender 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).
@@ -81,6 +81,16 @@ At this point you should be able to add a breakpoint and when you trigger it in
81
81
82
82
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.
83
83
84
+
### Editing Source Code
85
+
86
+
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).
87
+
88
+
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.
89
+
90
+
Open the file in VS Code, connect to the debugging server, make a change and save it.
91
+
92
+
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.
93
+
84
94
# Notes
85
95
86
96
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 unless you want to install it manually)
0 commit comments