Untitled
unknown
plain_text
a year ago
1.5 kB
9
Indexable
import bpy
class VertexCursorOperator(bpy.types.Operator):
bl_idname = "view3d.vertex_cursor_operator"
bl_label = "Move Cursor to Next Vertex"
_current_vertex_index: int = 0
def execute(self, context):
obj = context.active_object
if obj and obj.type == 'MESH':
vertices = obj.data.vertices
if len(vertices) == 0:
self.report({'WARNING'}, "No vertices found in the active object.")
return {'CANCELLED'}
# Przemieszczanie kursora do następnego wierzchołka
co = vertices[self._current_vertex_index].co
context.scene.cursor.location = obj.matrix_world @ co
self._current_vertex_index += 1
if self._current_vertex_index >= len(vertices):
self._current_vertex_index = 0 # Reset index to start over
return {'FINISHED'}
class VertexCursorPanel(bpy.types.Panel):
bl_label = "Vertex Cursor Panel"
bl_idname = "VIEW3D_PT_vertex_cursor_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Tool'
def draw(self, context):
layout = self.layout
layout.operator("view3d.vertex_cursor_operator")
def register():
bpy.utils.register_class(VertexCursorOperator)
bpy.utils.register_class(VertexCursorPanel)
def unregister():
bpy.utils.unregister_class(VertexCursorOperator)
bpy.utils.unregister_class(VertexCursorPanel)
if __name__ == "__main__":
register()
Editor is loading...
Leave a Comment