0
$\begingroup$

I want to get the final position of a vertice with an armature. I know how to do it in a local object, but the problem is how get the final position if the mesh is linked in the scene( the typical character linked with proxy in a scene)

I can get the initial position with this code, but whithout the armature modifier.

import bpy

a = bpy.context.object
if a.type == 'ARMATURE':
    grpname = a.proxy_group.name

    grp = bpy.data.groups[grpname]
    for o in grp.objects:
        if o.type == 'MESH':
            print(o.name)
            data = o.data
            for v in data.vertices:
                print(v.co)
        print("===================\n")
else:
    print("No armature selected")

To get the final in local I have used:

  apply_modifiers = ['ARMATURE', 'LATTICE']
    for m in myobj.modifiers:
        if m.type not in apply_modifiers and m.show_viewport is True:
            m.show_viewport = False

    # Apply modifiers
    me = myobj.to_mesh(scene=context.scene, apply_modifiers=True, settings='PREVIEW')
    myvertices = me.vertices
$\endgroup$
1
$\begingroup$

After ask the question, I had an idea:

import bpy

a = bpy.context.object
if a.type == 'ARMATURE':
    grpname = a.proxy_group.name

    grp = bpy.data.groups[grpname]
    for o in grp.objects:
        if o.type == 'MESH':
            print(o.name)
            for m in o.modifiers:
                print(m.name)

            # Apply modifiers
            me = o.to_mesh(scene=bpy.context.scene, apply_modifiers=True, settings='PREVIEW')
            myvertices = me.vertices
            for v in myvertices:
                print(v.co)

            if me is not None:
                bpy.data.meshes.remove(me)

        print("===================\n")
else:
    print("No armature selected")

You can use the same code that I used in local mode.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.