Reader small image

You're reading from  Python Scripting in Blender

Product typeBook
Published inJun 2023
PublisherPackt
ISBN-139781803234229
Edition1st Edition
Right arrow
Author (1)
Paolo Acampora
Paolo Acampora
author image
Paolo Acampora

Paolo Acampora is a 3D artist and programmer, with experience in Animation, Visual Effects, and Real Time computer graphics. He provides tools that streamline the production workflow and let artists focus on the creative aspects of their craft. He has worked with several studios for more than a decade. He contributes to the blender development and releases his tools for the community.
Read more about Paolo Acampora

Right arrow

External editor – Visual Studio Code

Visual Studio Code (VS Code), is a fast, multiplatform, free editor from Microsoft, available for Windows, macOS, and Linux. Using an external editor makes our code independent from a session of Blender. Also, a programmer text editor offers many utilities besides syntax highlighting.

VS Code 1.66 is used in this book. It is a fast, lightweight editor available for most platforms, but there are plenty of alternatives – most notably, the following:

Most Linux distributions come with at least one decent, ready-to-use, text editor. We encourage you to experiment and find the text editor of your choice.

In this section, we will set up VS Code for Python scripting.

Pick the right studio!

VS Code and Visual Studio have a similar name but are two different products from Microsoft. While VS Code is a programmer text editor, Visual Studio is a full development environment for advanced languages such as C++. While C++ projects may require a specific version of the building environment, it is safe to use any version of VS Code as long as Python is a supported language.

Loading our scripts folder

We can load the folder that contains our script files using the Open Folder… entry from the File menu. The editor will display the folder content on the first tab of the left column: the Explorer tab. Clicking on a .py file opens the script for editing.

Additional Python support can be installed by clicking Install on the bottom-right notification:

Figure 1.23: Our Python script in VS Code

Figure 1.23: Our Python script in VS Code

Keeping Blender’s text blocks in sync

When a text file open in Blender is changed by another application, a red question mark appears to the left of the filename:

Figure 1.24: Blender detects changes in a saved script

Figure 1.24: Blender detects changes in a saved script

Clicking the question mark displays the viable actions:

  • Reload from disk: This loads and displays the up-to-date file
  • Make text internal (separate copy): The displayed text is now part of the Blender session, no longer tied to any text file on disk
  • Ignore: Changes are ignored; Blender will still display the old text and keep reporting that it’s out of sync with the text saved on disk

To have additional help, we can add versioning to our files. That allows us to make changes without worrying about breaking things or losing our work.

Previous PageNext Page
You have been reading a chapter from
Python Scripting in Blender
Published in: Jun 2023Publisher: PacktISBN-13: 9781803234229
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Paolo Acampora

Paolo Acampora is a 3D artist and programmer, with experience in Animation, Visual Effects, and Real Time computer graphics. He provides tools that streamline the production workflow and let artists focus on the creative aspects of their craft. He has worked with several studios for more than a decade. He contributes to the blender development and releases his tools for the community.
Read more about Paolo Acampora