「Community:Science/Robotics/Blender25Panels」の版間の差分
細 (moved Robotics/Blender25Panels to Community:Science/Robotics/Blender25Panels: moving under Community:Science ("Community" being a new namespace)) |
細 (1版 をインポートしました) |
(相違点なし)
|
2018年6月29日 (金) 03:43時点における最新版
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:
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/buttons_scene.py
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):
'''docstring'''
__idname__ = "some.path.to.operator" # 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/export_ply.py 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.
bpy.ops.add(YourOperator)
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 bpy.data.scene.active cannot be called.