zeffii / bpy_script

a minimal declarative language for Blender Addon Scripts
2 stars 1 forks source link

scrub values in Blender Text Editor #2

Open zeffii opened 10 years ago

zeffii commented 10 years ago

Along the lines of tributary.io, i want to make Blender Text Editor a bit more interactive. Here's the primary checklist:

zeffii commented 10 years ago

int or float under cursor finder (ignores SI/complex e and j )

import re
k = "some_tandom=1.223123, paniw=30.000, gam = 0.0003, 40 1.23  =400"

def find_bounds(idx, k):
    ''' witness extreme lazyness '''

    pattern = '(=| |,|[a-zA-Z_])'
    less = re.sub(pattern, ' ', k)
    left = less[:idx].lstrip().split(' ')[-1]
    right = less[idx:].rstrip().split(' ')[0]
    summed = left + right
    print(summed)

for idx, ch in enumerate(k):
    print(ch, '->>', end='')
    find_bounds(idx, k)
zeffii commented 10 years ago

I was prepared to require no preselection, just have a cursor over a value and it detects the extents of that value by boundary.

def find_bounds(idx, k):
    ''' witness extreme lazyness '''

    pattern = '(=| |,|[a-zA-Z_])'
    less = re.sub(pattern, ' ', k)
    left = less[:idx].lstrip().split(' ')[-1]
    right = less[idx:].rstrip().split(' ')[0]
    summed = left + right

    if not summed:
        return
    else:
        begin = idx - len(left)
        end = idx + len(right)
        return summed, begin, end

Turns out I can't find how to set a selection given a line number and begin / end in a way that doesn't make me itchy.

This results in the requirement that one must select the entire value to scrub. After some thinking there is one up-shot to this situation - namely it allows for partial scrub. For instance if I have 12.234 I could select the last 2 numerics and scrub those for finer control, or the first 2 for rough control... or the whole thing for a level of control which might be specified depending on stacked sliders or regions in the slider.

Next up -- UI drawing. Fingers crossed, this can either be really fun or a nightmare :)

zeffii commented 10 years ago

https://gist.github.com/zeffii/7e28928a3da096cbc46a

zeffii commented 10 years ago

woooop

enzyme69 commented 10 years ago

Are all those now achievable via Script Node (Sverchok)?

I normally think Python script in bpy == once off procedure. Sometimes procedure can create mesh where we can use F6 to adjust.

While when it is like a Node, like Script Node, I feel more at peace because I could now slide values and see changes.

zeffii commented 10 years ago

continuous execution does require destruction / reconstruction of any created mesh if dealing with renderable meshes..BMesh viewer does this behind the scenes. I want to give this openGL and bmesh output, not sure it's possible -- The text editor is showing limitations already :[

This differs from purely scripted node stuff a lot, because scripted node you define which veriables can be input as sliders / sockets, whereas with continuous re-execution each number/float/bool could be become a popup UI when the text cursor is over it.

but I've only just started.. so we'll see.