3d cursor to selected vertex

I know nothing of scripting but does anybody know how to move the cursor to the selected vertices. the copy and paste thing does not work???

Check this out, I’ve found it very useful

https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Enhanced_3D_Cursor

You don’t need scripting for that, there’s an operator called Snap Cursor to Selected.

yes I know but not when its 1300 verts, I think ive figured a way to edit cloth. but thus far I’m going from vertex to vertex, I’m pretty excited because this may solve all those cloth problems!!

You can do it with a single vertex, 1300 verts or a million verts. If they are all selected you’ll get an average, if you don’t want that you can select one vertex at a time and run the operator, then you’ll get the exact match. Or use the vertex coordinates and place the 3d cursor there manually.

I used 2 scripts one to parent empty to every vertex and the other places a bone at every vertex. my problem is that the bone needs to follow the empty with a copy transforms. so I went to every bone and copy transform to empty took many hours. As oppose to a few seconds with a script.

Here are the 2 scripts

import bpy
import bmesh
context = bpy.context
scene = context.scene
obj = context.edit_object
mesh = obj.data
bm = bmesh.from_edit_mesh(mesh)
empties = []

selected verts

for v in [v for v in bm.verts if v.select]:
empty = bpy.data.objects.new(“Empty”, None)
empty.parent = obj
empty.parent_type = ‘VERTEX’
empty.parent_vertices = [v.index] * 3
scene.objects.link(empty)
empty.matrix_parent_inverse.identity()
empties.append((v.index, empty))

import bpy
from mathutils import Vector
from pprint import pprint
def AddBonesAtVertices(length = 1, use_normals = False):
scn = bpy.context.scene
if (None ==scn.objects.active):
return
obj = scn.objects.active
if (obj.type != ‘MESH’):
return
points = []
normals = []
data = []
for v in obj.data.vertices:
p = obj.matrix_world * v.co
target = v.normal * obj.matrix_world
dir = target - p
dir.normalize()
dir = dir * length
n = p + dir * (-1)
points.append§
if not use_normals:
n = Vector((p[0], p[1], p[2] + length))
pprint§
normals.append(n)
data.append([p, n])
amt = bpy.data.armatures.new(obj.name + “_vBones”)
rig = bpy.data.objects.new(obj.name + ‘_vRig’, amt)
scn.objects.link(rig)
scn.objects.active = rig
scn.update()
bpy.ops.object.editmode_toggle()
for i, l in enumerate(zip(points, normals)):
bone = amt.edit_bones.new(str(i))
bone.head = l[0]
bone.tail = l[1]
bpy.ops.object.editmode_toggle()

bpy.ops.object.mode_set(mode=‘OBJECT’)
AddBonesAtVertices(0.2)

Here is the final result, from a jumping crazy cloth to steady. Had to use anima all for final touch up.

I have solved the problem except the empties have a location of 0,0,0 i need them to have the location of the vertex, does anyone know how to fix this, since this script was copy and paste.

#select object and go into edit mode and run script.

import bpy
import bmesh

context = bpy.context
scene = context.scene
obj = context.edit_object
mesh = obj.data
bm = bmesh.from_edit_mesh(mesh)
empties = []

selected verts

for v in [v for v in bm.verts if v.select]:
empty = bpy.data.objects.new(“Empty”, None)
empty.parent = obj
empty.parent_type = ‘VERTEX’
empty.parent_vertices = [v.index] * 3
scene.objects.link(empty)
empty.matrix_parent_inverse.identity()
empties.append((v.index, empty))

bpy.ops.object.editmode_toggle()

context = bpy.context
scene = context.scene

Empty = [o for o in scene.objects if o.type == ‘EMPTY’]

for l in Empty:

add bone

bpy.ops.object.armature_add(location=l.location)
bpy.ops.object.posemode_toggle()
bpy.ops.pose.constraint_add(type=‘COPY_LOCATION’)
bpy.context.object.pose.bones[“Bone”].constraints[“Copy Location”].target = l
bpy.ops.object.posemode_toggle()

SOLVED!!

You then bake the armature to create an action. With the bake option of Only selected, Visual keying
Duplicate the mesh and remove cloth sim and duplicate armature and remove all constraints
Apply the duplicated armature to the duplicate mesh with auto weight paint.
Now you can join multiple bakes with baked actions, along with shape keys to fix cloth problems!!

#select object and go into edit mode and run script.

import bpy
import bmesh


context = bpy.context
scene = context.scene
obj = context.edit_object
mesh = obj.data
bm = bmesh.from_edit_mesh(mesh)
empties = []
# selected verts
for v in [v for v in bm.verts if v.select]:
    empty = bpy.data.objects.new("Empty", None)
    empty.parent = obj
    empty.parent_type = 'VERTEX'
    empty.parent_vertices = [v.index] * 3
    scene.objects.link(empty)
    
bpy.ops.object.editmode_toggle()




context = bpy.context
scene = context.scene


Empty = [o for o in scene.objects if o.type == 'EMPTY']


for l in Empty:
    # add bone
    bpy.ops.object.armature_add(location=l.location)
    bpy.ops.object.posemode_toggle()
    bpy.ops.pose.constraint_add(type='COPY_LOCATION')
    bpy.context.object.pose.bones["Bone"].constraints["Copy Location"].target = l
    bpy.ops.object.posemode_toggle()
    
bpy.ops.object.select_grouped(type='TYPE')
bpy.ops.object.join()
bpy.ops.object.posemode_toggle()
bpy.ops.pose.select_all(action='TOGGLE')
bpy.ops.pose.armature_apply()
bpy.ops.object.posemode_toggle()