Advertisement
Guest User

Untitled

a guest
Nov 30th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. import bpy
  2.  
  3. ### DISOLVE ###
  4.  
  5. class Disolve_ring_edges(bpy.types.Operator):
  6. """Tooltip"""
  7. bl_idname = "object.disolve_ring_edges"
  8. bl_label = "Disolve"
  9.  
  10. @classmethod
  11. def poll(cls, context):
  12. return context.active_object is not None
  13.  
  14. def execute(self, context):
  15. bpy.ops.mesh.loop_multi_select(ring=True)
  16. bpy.ops.mesh.select_nth()
  17. bpy.ops.mesh.loop_multi_select(ring=False)
  18. bpy.ops.mesh.dissolve_edges()
  19. return {'FINISHED'}
  20.  
  21. ### ORIGIN_TO_SELECTED ###
  22.  
  23. class Origin_to_selected(bpy.types.Operator):
  24. """Tooltip"""
  25. bl_idname = "object.origin_to_selected"
  26. bl_label = "Origin to selected"
  27.  
  28. @classmethod
  29. def poll(cls, context):
  30. return context.active_object is not None
  31.  
  32. def execute(self, context):
  33.  
  34. original_type = bpy.context.area.type
  35. bpy.context.area.type = "VIEW_3D"
  36. bpy.ops.view3d.snap_cursor_to_active()
  37. bpy.context.area.type = original_type
  38. bpy.ops.object.editmode_toggle()
  39. bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
  40. bpy.ops.object.editmode_toggle()
  41. bpy.ops.mesh.select_all(action='DESELECT')
  42. return {'FINISHED'}
  43.  
  44. ### PANEL ###
  45.  
  46. class View3DPanel(bpy.types.Panel):
  47. bl_label = "Анонче"
  48. bl_idname = "OBJECT_PT_hello"
  49. bl_space_type = 'PROPERTIES'
  50. bl_region_type = 'WINDOW'
  51. bl_context = "object"
  52.  
  53. def draw(self, context):
  54.  
  55. layout = self.layout
  56.  
  57. row = layout.row()
  58. row.label(text="Ну как так то", icon='WORLD_DATA')
  59.  
  60. row = layout.row()
  61. row.operator("object.disolve_ring_edges")
  62.  
  63. row = layout.row()
  64. row.operator("object.origin_to_selected")
  65.  
  66.  
  67. def register():
  68. bpy.utils.register_class(Disolve_ring_edges)
  69. bpy.utils.register_class(Origin_to_selected)
  70. bpy.utils.register_class(View3DPanel)
  71.  
  72.  
  73. def unregister():
  74. bpy.utils.unregister_class(Disolve_ring_edges)
  75. bpy.utils.unregister_class(Origin_to_selected)
  76. bpy.utils.unregister_class(View3DPanel)
  77.  
  78.  
  79. if __name__ == "__main__":
  80. register()
  81.  
  82.  
  83.  
  84. ## # test call
  85. # bpy.ops.object.simple_operator()
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement