blender_vscode icon indicating copy to clipboard operation
blender_vscode copied to clipboard

Support running `Blender: Run Script` with single button 🔥

Open Mateusz-Grzelinski opened this issue 5 months ago • 1 comments

This branch is continuation of #199 but with focus on Blender: Run Script. Lets deal with 199 first, here I also made many changes.

  • Improvements for Blender: Run Script:
    • When no Blender instances are running, run Blender: Start and then immediately run Blender: Run Script
    • When Blender instances are running, just run the script on all available instances (old behavior)
    • Specify default Blender: Start configuration in settings using isBlenderRunScriptDefault in blender.executables
    • Run Blender: Run Script using single button by adding snippet to keybindings.json.
  {
    "key": "ctrl+shift+enter",
    "command": "blender.runScript",
    "args": {
       // optional, must be absolute path, defaults to current open file
      "path": "E:\\BlenderProjects\\leagacy_and_extension\\i.py"
    },
    "when": "editorLangId == 'python'"
  }

TODO:

  • more testing needed, also on different platforms, especially different commands
  • [x] when blender fails to start we need to clear registered callbacks
    • [x] blender can be run with launchDebug: add identifier to debug config to know which instance to clean
    • [x] or launch: we can track task._id to know when to clear callbacks using tasks.onDidEndTaskProcess
  • [x] specify optional file to run
  • [x] RunningBlenders might have invalid BlenderInstance - actually they are never cleared

Mateusz-Grzelinski avatar Sep 08 '24 20:09 Mateusz-Grzelinski