Tutorial one: how to go all meta on the bpy panel/operator thing

bl_info=dict(name='SelTools',author='dustractor',version='(1,1)',blender='(2,5,8)',api='33333',location='View3d > UI panel > SelTools',description='Selection Tools',category='3D View')
import bpy
a=lambda x,y:print(x,y)
b=lambda x,y:print(dir(x))
ops=['object.meta1','object.meta2']
class Op(bpy.types.Operator):
@classmethod
def poll(self,context):
return context.active_object!=None
def invoke(self,context,event):
self.execute(context)
return {'FINISHED'}
def execute(self,context):
self.f(context)

class selectionPanel(bpy.types.Panel):
bl_label,bl_space_type,bl_region_type=['Selection Tools','VIEW_3D','UI']
def draw(self,context):
list(map(lambda x:self.layout.row().operator(x),ops))

meta1=type("meta1",(Op,),{'bl_idname':'object.meta1','bl_label':'meta one','f':a})
meta2=type("meta2",(Op,),{'bl_idname':'object.meta2','bl_label':'meta dos','f':b})

registry=[meta1,meta2,selectionPanel]
def register():list(map(lambda x:bpy.utils.register_class(x),registry))
def unregister():list(map(lambda x:bpy.utils.unregister_class(x),registry))
if __name__=='__main__':register()

thats it. proof of concept. good night bowl of oatmeal.

Advertisement
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.