Quick Start

Note

This Quick Start page and tutorial is shown using free version. After this page, head over to Tutorial Section

You can get started with free version Quick Run Free. Check Installation page for details.

'quick run'

For example, look at following code of creating cube from Comparisons page

create_cube.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import bpy
from boss.ui_creator import UICreator

def onEnterPress(caller):
    bpy.ops.mesh.primitive_cube_add(size=2)
    bpy.context.object.name = caller.value
    caller.op.quit()  # to quit after the button is clicked.


def ui_elements(op):
    UICreator.deleteAllUi(op)  # to delete all existing ui
    btn_width, btn_height = 100, 40

    rr = UICreator.rr(op)  # region_rect(rr)

    rd = (
        rr.width/2 - btn_width/2,
        rr.height/2 - btn_height/2,
        btn_width,
        btn_height
    )
    UICreator.textField(
        op,
        rectData=rd,
        text='Cube',
        onEnterPress=onEnterPress
    )

How would you run above create_cube.py script? Read the following section.


Important Scripts

Two Scripts are placed in the script directory.
  1. run_clipboard.py

  2. run_qr_text.py

'important buttons'

These scripts are helpful to test scripts before saving code in a file.

run_clipboard.py

This is a one-liner script that helps to run text on clipboard.

run_clipboard.py
1
2
import bpy
exec(bpy.context.window_manager.clipboard)

copy the above create_cube.py text and press run_clipboard.py button. This code runs!!!!

Note

This one liner script is useful for testing code easily by coping from web-browser or external /internal text-editor. This way, you can run example scripts shown in documentation, including all the code in the tutorial section.

run_qr_text.py

This is another small script, which cuts the step of copying the text. If your code is in qr_text named TextData block in TEXT_EDITOR, You can launch the quick_run/free and press run_qr_text.py. This way, if you want to modify code(eg you copied from tutorial), you can do that in text editor and press run_qr_text.py

import bpy

if 'qr_text' in bpy.data.texts:
    # exec(curText.as_string())
    exec(bpy.data.texts['qr_text'].as_string())
else:
    t = bpy.data.texts.new('qr_text')
    t.write('# paste code here\n')

Note

These scripts are very helpful since, sometimes it can be used to avoid wrong context - poll failed error, which is very common when copying code from info panel. You can launch quick_run/free in the correct region/space and problem may be avoided.


Saving your Script

If you want to save, create_cube.py ,first copy the text, press Scripts Directory it will open the folder. Create the file create_cube.py and paste the text in the file. Relaunch addon (press F2)

Important

By default all the scripts are saved in a sub-directory within addon install directory. You must change the root directory in settings.

This way, if you have multiple blender installation, they all can use same root/script directory. Second, You can open root directory in external editor(eg VSCode). Further, You can save your codes in github.( and doing all that inside a subdirectory of addon doesn’t feel right!!)


ui_elements

ui_elements is name of function that is called by quick_run/_free. It’s hardcoded. It could just as well have been foo.

ui_elements is also name of method that is overridden in the class to create UI. check here convert script to addon.