0

I read a lot ( 3 full days) on the subject but none of it helped me.

For instance when I pushed a mesh operator in my console I got a "CANCELED" result. Not an error, just "CANCELLED".

I would like to edit part of high resolution meshes by applying mathematical equations to them.

The workflow is:

  • Select the zone where the equation will apply.
  • Tweak the equation.
  • Tweak the selection.
  • Tweak the equation a bit more.

This works very fine with the models where the Index follow the UVs (Index 0-31 for the first U row, 32-63 for the second … and so on for a 32 U vertices model).

On all the real workday’s models the Index are never in accordance with the UVs because of the added cuts and so on. So I would like to be able to get the u and v of any vertex. Is there a way to do this, either with a script or directly from the 3D viewport layout or UV editor or…

I will be working inside Geometry Nodes so the vertex groups are not really an option since they are very awkward to edit after they are made. Unless there is an automatic way to put each U row in a group once and for all.

Anyway, as you see, I am open for suggestions.

The purpose of all this is to control difficult parts of the mesh without clicking the mesh itself.

1 Answers1

1

Useful settings

![](user_prefs.png)

Ensure developer extras is enabled in edit > preferences > interface > display

![](tooltips.png)

This will allow you to enable indices as an overlay option in your viewport display.

![](vert%20index%20display.png)

When enabled the indices of selected vertices or edges or faces are displayed depending on selection mode.

Based on Jaroslav Jerryno Novotny's answer here.

The below script will enable a panel in the 3d viewport that allows you to select an object and a vertex index and will provide the local vertex coordinates and uv coordinates.

![](panel.png)

Simply select the object in the drop down and set the vertex index.

import bpy

def pointer_poll(self, context): return context.type == 'MESH'

def pointer_cb(self, context): my_props = context.scene.test_pg my_props.sel_vert_idx = 0 return

def get_single_vert_uv(context): my_props = context.scene.test_pg obj = my_props.obj my_uv = None for face in obj.data.polygons: for vert_idx, loop_idx in zip(face.vertices, face.loop_indices): uv_coords = obj.data.uv_layers.active.data[loop_idx].uv if vert_idx == my_props.sel_vert_idx: my_uv = uv_coords return my_uv

class VIEW3D_PT_test(bpy.types.Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' bl_category = "Testing" bl_idname = "VIEW3D_PT_test" bl_label = "Panel 1"

def draw(self, context):
    my_props = context.scene.test_pg
    layout = self.layout
    box = layout.box()
    col = box.column(align=True)
    col.prop(my_props, "obj")
    col.prop(my_props, "sel_vert_idx")
    col.label(text=f"vert coord: {my_props.obj.data.vertices[my_props.sel_vert_idx].co}")
    col.label(text=f"uv_coord: {get_single_vert_uv(context)}")


def max_len(self, context): my_props = context.scene.test_pg if my_props.sel_vert_idx > len(my_props.obj.data.vertices)-1: my_props.sel_vert_idx = len(my_props.obj.data.vertices)-1

class TEST_PG_props(bpy.types.PropertyGroup): sel_vert_idx: bpy.props.IntProperty( name="sel_vert_idx", min=0, update=max_len, ) obj: bpy.props.PointerProperty( type=bpy.types.Object, update=pointer_cb, poll=pointer_poll, )

classes = [ VIEW3D_PT_test, TEST_PG_props, ]

def register(): for cls in classes: bpy.utils.register_class(cls) bpy.types.Scene.test_pg = bpy.props.PointerProperty( type=TEST_PG_props)

def unregister(): for cls in classes: bpy.utils.unregister_class(cls) del bpy.types.Scene.test_pg

if name == "main": register()

Ratt
  • 2,126
  • 1
  • 10
  • 17
  • Wow, thanks. That's a comprehensive answer. I'll get to it today and keep you posted in case of success. – John Smith Images Apr 11 '22 at 05:14
  • One hour later: It works. I even understood the code. It gives me the UV coordinates of the selected vertex as they are in the UVmap from Geometry Nodes. Once my UVmap is a rectangle, the vertices on a U/V loop have the same Y/X coordinates. Then it is just a matter of maths to select the vertices. – John Smith Images Apr 11 '22 at 06:49