Page MenuHome

to_mesh() for evaluated object not work with shape key
Closed, ResolvedPublic


System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: GeForce GTX 980 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64

Blender Version
Broken: version: 2.80 (sub 67), branch: master, commit date: 2019-05-16 13:21, hash: rBbd0f26e2de7b
Worked: 2.7 and other 2.80 versions untill new dependency update

Short description of error
evaluated object , to_mesh() not return mesh which armature modifier applied when original object have shape keys

Exact steps for others to reproduce the error

1 load attached blend file. then go to Script work space. (if not)

2 select "cylinder" which deformed by armature modifier and no shape key.
3 Run registered script. ( it generate new obj named as cylinder_clean .)

(or download attached and load in script editor, then Run script )

4 confirm generated new object is armatrue modifier applied, and same shape of "cylinder"
(so to_mesh work as expected for evaluated object)

5 to keep view clean, hide the cylinder_clean, and cylinder objects.

6 select "cylinder_keys" which deformed by armature modifier , but basis shape key are added. (copied object of "cylinder", just add basis shape key so they are identical objects)
7 run script. it generate new obj named as cylinder_key_clean
8 the new generated obj are not applied armature modifier. (as if it remove modifier not applied)

untill e693918d4074
" to_mesh()" could generate mesh which modifier and current shape key values applied with option.

(mesh = obj.to_mesh(bpy.context.depsgraph, True)

and it was important function to get same mesh as view. but at current there seems no alternative way to achieve same thing. (shape key + modifier apply)



Event Timeline

Then after generate Cylinder_keys_clean, , remove shape key (basis) from
Cylinder_keys (original mesh), and run-script again, blender 2.8 shut down too.
(there already clash report about evaluated obj , to_mesh() , T64731 T64735
so I think the clash of my case is related too.

Have you tried

MACHIN3 thanks advice. then no. I just tried to use to_mesh() for up-date some add on for 2.8
. so I need to use for the purpose?

If it can do same thing which I could by (obj.to_mesh(bpy.context.depsgraph, True)) I apreciate.
before it worked with true option.

Then could you take time to edit my really simple to work so? or tell me link etc,
of sample script which use new_from_obj? (just apply current shape key values, with modifier)

Thanks MACHIN3 it worked to generate mesh which shape keys mix value + armature modifier applied

mesh = is alternative of removed " obj.to_mesh(depth, True)"?

MACHIN3 (MACHIN3) added a comment.EditedMay 17 2019, 12:22 PM

Check out was Sergey told me:

Basically, if you want to use the evaluated mesh as part of the blend file, for instance by assigning it to some, you need to use now.

to_mesh() can still be used, if you want to do math on the mesh, or perhaps for bmeshes as well, I'm not sure yet. If you do use to_mesh(), note that it doesn't have any arguments anymore, it's just to_mesh().
The result of to_mesh() is shortlived, it doesn't stay around, hence why you can't use it for

Also see and

I see, really thanks you take time to guide me details ^^

when I saw this depthgraph up-date ,I afraid I will lost way for shape key. then reported it and asked first.

because I know when apply modifier, I need to apply shape keys, (if do it from blender UI) but it is not good when I need to re-use the original .or I need to keep copy. then hoped answer from developer.

Anyway I could get answer from you, and Now I can clear understand how it will work.

Happy to help. Good luck.

Note: started the patch which is aimed to help spotting such mistakes more easily: D4884.