利用者:Ianwill/tmp

提供: wiki
移動先: 案内検索

Blender Assistant

I'm considering adding functionality similar to Enso in Blender.

This was inspired by the integrated search box in Blender, Enso, a suggestion by artist Lucio Cavalcanti to add scene data search to the integrated search and talking to devs kaito and dfelinto.

It would be a string box popup (similar to the integrated search one) that users can open and use to type commands that perform actions in Blender. The syntax should be as close to very simplified human language as possible (leave serious programming to Python scripting).

General Guidelines

  1. Should be simple: following Python's way, it's better to have ONE well-defined, preferably simple way to do each thing than many ways.
  2. Should be natural: for programmers we already have Python. This should be as close to human language as possible.
  3. Should be expressive: SHORT, simple and natural.

Possible commands and syntax

Note: any command issued to the assistant is called here an "action".

General Patterns: example

  • command: undo
  • command objects: select meshes
  • command objects filter: select meshes from layer 3
  • command-part1 objects command-part2: select cameras as MyCameras

Possible filters:

  • qualifiers:: all: all meshes, only: only lamps
  • restricting:: from: from layer 2, linked to: linked to material Mat.001, where: meshes where name = something.00*

Tentative Syntax

Reserved keywords

  • selection # the current selection
  • as, from, to
  • create, add, remove
  • layer, group
  • linked to, with, where
  • origin
  • date
  • is
  • =, &, |, +, -

Selecting

Cases:

  1. list or define selected objects in Blender (add to, remove from, clear)
  2. list or define our own selections.

For our own selections, which are just helpers for actions and are not automatically exported to Blender (but can be explicitely), we can use Python sets and enjoy all their features easily.

  • select all cameras as set MyCameras

better, let's omit the word "set":

  • select all cameras as MyCameras
  • from MyCameras remove Camera.003
  • select all from MyCameras
  • select all lamps from MySceneObjects

So:

  • select <something> # adds to Blender selection
  • select <something> as set SetName # adds to our own set called SetName, not Blender
  • select set SetName # selects in Blender
  • select <something> from set SetName # selects in Blender
  • select <something> from set SetName as set SetName2 # new set SetName2

It may be interesting to support booleans on set operations:

  • set S3 is intersection of set S1 and set S2
  • S3 = S1 & S2 # using Python set syntax for intersections
  • set S3 is S1 - S2 # difference
  • S3 = S1 | S2 # union

Create, Add and Remove

Create, add and remove can become general actions that work in many situations.

  • create mesh TestMesh1
  • create group GroupA from MySelection
  • create group CurSel from selection

Random ideas

Just to get a feel for it, let's list examples of actions users might want to type. Actual implementation should focus on the simple ones first, naturally.

(been editing this to try to get a minimal language out of it)

  • Selection
  1. select all lamps
  2. select all cameras as MyCameras
  3. select meshes only
  4. select Cube.002
  5. select all except lamps
  6. select all - lamps
  7. select meshes with modifiers
  8. select all objects linked to material Gold.001
  9. add all meshes linked to texture Bricks to MySelection
  10. deselect all
  11. deselect all metaballs
  12. deselect all lamps from MySelection3
  13. remove all lamps from MySelection3 # only remove from selection MySelection3
  14. delete all lamps in MySelection3 # delete from Blender
  15. deselect Camera.001 from MyCameras

Note: about behavior, 'select' may overwrite the previous selection and then we have to use 'add ... to selection' to keep the previous selection or 'select' adds by default and we use words like 'only' to get rid of the previous selection: 'select all meshes only'.

  • On/Off
  1. disable all modifiers
  2. disable all display modifiers
  3. disable all render subsurf modifiers
  4. disable ray tracing
  5. enable sss
  • Creation / deletion
  1. delete all area lights
  2. delete all meshes in layer 3
  3. add Suzanne at 10,200,0
  4. add red sphere on top of Cube.001
  5. add text "Hello, World!" at Plane.002 + 0,0,10
  6. add text date mm-dd-yy
  7. duplicate Circle.001 as NewCircle in layer 9
  • Settings:
  1. rename Cube.002 to Airplane
  • Commands:
  1. center Cube.001 at origin
  2. remove doubles threashold=0.01 from selected meshes
  3. set Cube.001 smooth
  1. Groups and layers
  2. move all lights to layer 3
  3. add Cube.001, Cube.002 to group Cubes
  • Transformations:
  1. move Cube to 0,0,0
  2. move all meshes with modifiers to layer 3
  3. resize Circle to 1, 3
  4. resize Circle to 100%, 300%
  5. rotate Cube 30 degrees around x
  • Transform combo:
  1. move Cube.001 to Cube.002 + 0,0,100
  2. rotate Cube.001 90 degrees around Cube.002
  1. repeat
  2. repeat action 10
  3. revert
  • General "File Menu" actions:
  1. save newfile.blend
  2. load oldfile.blend
  3. export all meshes with textures to collada as myfile.dae
  • Text operations
  1. replace "blender" by "Blender" in Mytext.txt
  2. uppercase all in Mytext.txt at line 1
  • A list action that creates a list inside the popup itself, like with the integrated search box:
  1. list previous 10 actions
  2. list all objects named car-parts*
  3. list selected
  4. list all from MySelection
  5. list all selection groups
  6. list meshes that use material Red
  • Make macros from actions:
  1. macro actions 7-10 as mymacro
  2. run mymacro
  1. undo
  2. redo

Note: action undo / redo or Blender undo / redo? If Blender commands have been done between actions, these are different things. Maybe keep undo / redo for Blender and repeat / revert / ??? for actions or also accept 'undo action', 'redo action'.

  • Help:
  1. help wiki
  2. help manual
  3. help eshop
  4. help python

Other possibilities:

  • Evolve to a simple language:
  1. while n < 100: add Cube at n, 0, 0; n += 10
  • Maybe something inspired by the old Logo programming language.

General Notes

This is all very early, I'm just brainstorming. Planning to start small (some examples here may be better left for Python scripting, let's see).

Obviously this intersects with Python scripting in Blender. We need to think carefully about where to define a clear line between what this assistant can do and what should be left to pure Python scripts.

The commands only need to be typed up to where they are clearly recognized, so 'select' can be written simply as 'sel'.

Considering having multiple ways to access data returned by actions. In the outliner, the returned lists would appear in the outliner itself. In other editors, like the 3D View, they would appear in the command box itself. In the Text editor commands could act in the text itself ("replace "blender" by "Blender", find "some word").

Since this should be for all users, following how the integrated search shows possible ways to complete a command is ideal. Something general, indicating next steps clearly. For example: with a blank text box, it shows the list of possible / common actions to type. With a command typed, it shows possible ways to follow it.