Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- ### DISOLVE ###
- class Disolve_ring_edges(bpy.types.Operator):
- """Tooltip"""
- bl_idname = "object.disolve_ring_edges"
- bl_label = "Disolve"
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
- def execute(self, context):
- bpy.ops.mesh.loop_multi_select(ring=True)
- bpy.ops.mesh.select_nth()
- bpy.ops.mesh.loop_multi_select(ring=False)
- bpy.ops.mesh.dissolve_edges()
- return {'FINISHED'}
- ### ORIGIN_TO_SELECTED ###
- class Origin_to_selected(bpy.types.Operator):
- """Tooltip"""
- bl_idname = "object.origin_to_selected"
- bl_label = "Origin to selected"
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
- def execute(self, context):
- original_type = bpy.context.area.type
- bpy.context.area.type = "VIEW_3D"
- bpy.ops.view3d.snap_cursor_to_active()
- bpy.context.area.type = original_type
- bpy.ops.object.editmode_toggle()
- bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
- bpy.ops.object.editmode_toggle()
- bpy.ops.mesh.select_all(action='DESELECT')
- return {'FINISHED'}
- ### PANEL ###
- class View3DPanel(bpy.types.Panel):
- bl_label = "Анонче"
- bl_idname = "OBJECT_PT_hello"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "object"
- def draw(self, context):
- layout = self.layout
- row = layout.row()
- row.label(text="Ну как так то", icon='WORLD_DATA')
- row = layout.row()
- row.operator("object.disolve_ring_edges")
- row = layout.row()
- row.operator("object.origin_to_selected")
- def register():
- bpy.utils.register_class(Disolve_ring_edges)
- bpy.utils.register_class(Origin_to_selected)
- bpy.utils.register_class(View3DPanel)
- def unregister():
- bpy.utils.unregister_class(Disolve_ring_edges)
- bpy.utils.unregister_class(Origin_to_selected)
- bpy.utils.unregister_class(View3DPanel)
- if __name__ == "__main__":
- register()
- ## # test call
- # bpy.ops.object.simple_operator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement