1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| bl_info = { "name": "pyw_tools", "author": "PYW", "version": (1, 0), "blender": (2, 80, 0), "location": "见视图右边工具栏", "description": "PYW实用工具", "warning": "", "doc_url": "", "category": "PYW", }
import bpy
class drop2floor(bpy.types.Operator): bl_idname = "obj.align_to_floor" bl_label = "对齐地面" def execute(self, context): bpy.ops.object.align( align_mode = 'OPT_1', relative_to = 'OPT_1', align_axis = {'Z'}) return{'FINISHED'}
class drop2floor_UI(bpy.types.Panel): bl_label = "align_to_floor" bl_idname = "align_to_floor" bl_space_type = "VIEW_3D" bl_region_type = "UI" bl_category = "PYW" def draw(self,context): layout = self.layout row = layout.row() row.label(text='将物体对齐地面', icon='SHADING_SOLID') row = layout.row() row.operator("obj.align_to_floor", icon="PMARKER_SEL")
def register(): bpy.utils.register_class(drop2floor) bpy.utils.register_class(drop2floor_UI)
def unregister(): bpy.utils.unregister_class(drop2floor) bpy.utils.unregister_class(drop2floor_UI)
if __name__=="__main__": register()
|