← All ideas

Center Cursor in UV Editor

I would like the center view / cursor command to work in The UV editor.

I often find myself having to type in the center coordinates to center the cursor.

Granted it is much nicer with texture space coordinates, but I would like "center cursor and view all" to work in the UV editor.

Or add a "Center" option to snap cursor.

This would put the cursor at 0.5,0.5 in texture coordinate mode, or half of the width and height in pixel coordinate mode.

100%

Development Status: Done

Upvote 6 Downvote 0
OldVamp
8 Jan 2021

3 Comments

OldVamp Author

Finally got around to making one

# ***** BEGIN GPL LICENSE BLOCK *****
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# https://www.gnu.org/licenses/gpl-3.0.html
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****

bl_info = {
    "name": "Center UV Cursor Button",
    "author": "OldVamp",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "UV editor > UI pannel > view > 2D Cursor Center",
    "description": "Centers the UV cursor so you don't have to: click 0.5 tab 0.5 enter",
    #"warning": "",
    #"doc_url": "",
    "category": "Material"
    # Jan 8 2021
}

import bpy

def CenterUV():
    for area in bpy.context.screen.areas:
        if area.type == 'IMAGE_EDITOR':   #find the UVeditor
            area.spaces.active.uv_editor.show_pixel_coords = False
            area.spaces.active.cursor_location = 0.5,0.5


class OVDoCenter2DCursor(bpy.types.Operator):
    bl_idname = "ov.centercursor"
    bl_label = "Center 2D Cursor"
    bl_description = "Centeres the 2D cursor in image editing panel"
    bl_register = True
    bl_undo = True
    @classmethod
    def poll(cls, context):
        return True
    def execute(self, context):
        CenterUV()
        return {'FINISHED'}


class OVCenterCursorPanel(bpy.types.Panel):
    bl_label = "2D Cursor Center"
    bl_idname = "OBJECT_PT_UVCenter"
    bl_space_type = 'IMAGE_EDITOR'
    bl_region_type = 'UI'
    bl_category = "View"

    def draw(self, context):
        layout = self.layout

        layout.label(text="2D Cursor")
        row = layout.row()
        row.scale_y = 2.0
        row.operator("ov.centercursor", text='Center', icon='EMPTY_DATA')


def register():
    bpy.utils.register_class(OVCenterCursorPanel)
    bpy.utils.register_class(OVDoCenter2DCursor)


def unregister():
    bpy.utils.unregister_class(OVCenterCursorPanel)
    bpy.utils.unregister_class(OVDoCenter2DCursor)


if __name__ == "__main__":
    register()
Traaxxe

* @OldVamp * I'm trying to install this addon, but I don't know how to pack it. What do I name the files?

jason

Seems like something easily put together as an add-on.