Skip to content

Commit b2a3857

Browse files
committed
Documented how to Edit Blender's Source Code
1 parent 35e8ca3 commit b2a3857

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

README.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Now it can:
1212

1313
# How to Use
1414

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.
1616

1717
## Installing Python and Getting PTVSD
1818

1919
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.
2121

2222
`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.
2424

2525
## Setting up your Addon
2626

@@ -31,11 +31,11 @@ In Blender go to: `User Preferences > File` and set the path to `Scripts` to the
3131
```
3232
Blender Stuff
3333
└── 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+
├── ...
3939
```
4040

4141
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.
6161
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.
6262

6363
```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+
},
7474
```
7575

7676
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
8181

8282
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.
8383

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+
8494
# Notes
8595

8696
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

Comments
 (0)