利用者:Ianwill/tmp
目次
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
- 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.
- Should be natural: for programmers we already have Python. This should be as close to human language as possible.
- 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:
- list or define selected objects in Blender (add to, remove from, clear)
- 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
- select all lamps
- select all cameras as MyCameras
- select meshes only
- select Cube.002
- select all except lamps
- select all - lamps
- select meshes with modifiers
- select all objects linked to material Gold.001
- add all meshes linked to texture Bricks to MySelection
- deselect all
- deselect all metaballs
- deselect all lamps from MySelection3
- remove all lamps from MySelection3 # only remove from selection MySelection3
- delete all lamps in MySelection3 # delete from Blender
- 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
- disable all modifiers
- disable all display modifiers
- disable all render subsurf modifiers
- disable ray tracing
- enable sss
- Creation / deletion
- delete all area lights
- delete all meshes in layer 3
- add Suzanne at 10,200,0
- add red sphere on top of Cube.001
- add text "Hello, World!" at Plane.002 + 0,0,10
- add text date mm-dd-yy
- duplicate Circle.001 as NewCircle in layer 9
- Settings:
- rename Cube.002 to Airplane
- Commands:
- center Cube.001 at origin
- remove doubles threashold=0.01 from selected meshes
- set Cube.001 smooth
- Groups and layers
- move all lights to layer 3
- add Cube.001, Cube.002 to group Cubes
- Transformations:
- move Cube to 0,0,0
- move all meshes with modifiers to layer 3
- resize Circle to 1, 3
- resize Circle to 100%, 300%
- rotate Cube 30 degrees around x
- Transform combo:
- move Cube.001 to Cube.002 + 0,0,100
- rotate Cube.001 90 degrees around Cube.002
- repeat
- repeat action 10
- revert
- General "File Menu" actions:
- save newfile.blend
- load oldfile.blend
- export all meshes with textures to collada as myfile.dae
- Text operations
- replace "blender" by "Blender" in Mytext.txt
- 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:
- list previous 10 actions
- list all objects named car-parts*
- list selected
- list all from MySelection
- list all selection groups
- list meshes that use material Red
- Make macros from actions:
- macro actions 7-10 as mymacro
- run mymacro
- undo
- 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:
- help wiki
- help manual
- help eshop
- help python
Other possibilities:
- Evolve to a simple language:
- 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.