Menu

Filter

Social

Run python command in Blender from 3D view

Are you tired of getting the “RuntimeError: context is incorrect” error when trying to run python commands in Blender?!? Of course you are!!
But sweat no more – thanks to this new and super simple Blender addon, you can run your python commands directly from any 3D view and get the correct context – always! This is solution to blender context is incorrect problem you have been waiting for!
But wait!!! There is more! You can run either a single line or even execute whole script documents!
So forget about writing addons or doing complex context copy operations just to run that one modelling operator you need! Download now and get your own python command line directly in your 3D view!

It just makes life much simpler when you want to run small scripts that use 3D view dependent operators on your scene objects. It would be fantastic if there would be a way to enable syntax hilighting and autocomplete in the line input, but unfortunately it is not possible now.

Update: Added default keyboard shortcuts “Shift Alt X” runs a line and “Ctrl Alt X” runs a script. You can of course change the shortcuts in preferences if you like. Re-download and reinstall addon to have shortcut keys added automatically.

solution to blender context is incorrect

Run python script from blender 3d view and get correct operator context!

You can download the script here!

4 thoughts on “Run python command in Blender from 3D view”

  1. Jamie
     ·  Reply

    Thanks man! Saved my bacon.

  2. Juha Wiiala
     ·  Reply

    Thank you Gatis.

  3. todd doehring
     ·  Reply

    This looks great, but when I run it all I get is this:

    Traceback (most recent call last):
    File “C:\Users\tcdoe\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\python_panel.py”, line 62, in execute
    exec(code)
    File “”, line 23, in
    File “”, line 23, in
    NameError: name ‘objcurve’ is not defined

    BUT if you look the code below (simple) the object is defined and it works fine running from text editor or python console.

    I must be missing something!!! hope you can help.
    thanks,
    Todd

  4. todd doehring
     ·  Reply

    Simple code here:

    obj = bpy.context.active_object
    objdata = bpy.context.active_object.data

    vertices = objdata.vertices
    objcurve = obj
    #print(objcurve)
    #raise Exception()
    vertstarg = [objcurve.matrix_world * vert.co for vert in vertices]

    The error occurs in the last line just computing a simple transformation…

Leave a Reply

Your email address will not be published.

*