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

Panels in Blender 2.5

Blender 2.5 allows to customize the UI through Python scripting. This means that without changes to the code base, one can introduce custom panels.

A panel, in Blender jargon, is an area as shown below:

Robotics - Blender 2.5 Panel.png

You can add your desired features/scripts to such a Blender panel, in order to make them accessible with one click.

We should choose a location for our panel. Currently Buttons->Scene but maybe Buttons->armature or Buttons->Bone might be interesting as well. To add a function button you have to edit /.blender/ui/

add <row/column>.itemO("<yourOperator>", text="<the text shown in gui", icon='<youricon, can be left empty>'))

to the wanted panel. Now you have to add your script. Make a new Python file which should be like

  import bpy
  class YourOperator(bpy.types.Operator):
       __idname__ = "" # like "myops.myop"
       __label__ = "The string you see ie. in command search (ctrl+space)" 
                    # like "My Operator"
       __props__ = [] # list of props used, see release/io/ for example
       def poll(self, context):
               # checks to ensure your operator has what it needs
               return True # or False if context is not correct, ie no selected objects
       def execute(self, context):
               # your main part of the script should come in execute
               return ('FINISHED', ) # or 'CANCELLED' or any of the others,
                depending on what you need. 

To ensure that your own operator actually gets registered to the operator system, you have to add the last line!

For now, however, the scripting capabilities of 2.5 don't seem to be sufficiently extended, for example, a cannot be called.