Ob.to_mesh() problems with API changes

Dear all,
trying Tissue with the latest versions of Blender, I realised that now the python method me0 = ob0.to_mesh(context.scene.depsgraph, True) is not working anymore.
Now it is just me0 = ob0.to_mesh(). And I’m fine with that, even easier. So I changed all Tissue lines, but now if I use it, after that I get this message:

ob0.data = me0
RuntimeError: Error: Can only assign evaluated data to to evaluated object, or original data to original object

This message is really new to me, so my only idea was creating a copy of the mesh:
ob0.data = me0.copy()

But now it crash!!! :fearful:
I think that the crash doesn’t occur in that line, but maybe to something that depends on that…

Please tell me that there is a simple solution for that… or that I just have to wait for some fixes by Blender developers…

Hi, it would be great if you could provide a concise script that shows this behavior. specially with the crash. Being able to reproduce the issue quick and with no dependencies (e.g., not having to download/install Tissue) helps for a faster triage (in case this is a bug).
Also, did it work in a previous version of Blender? which commit hash are you in?
Is this the branch you are working for the updates? https://github.com/alessandro-zomparelli/tissue/tree/b280-dev

Documentation is here:

Also note that the version of this add-on in the Blender add-ons repository was updated to work with the new depsgraph API (though without much testing).


Thanks @brecht! I haven’t seen it. I definitely have to connect with the add-on repository. It’s something that I’m still procrastinating…
I’ll test it. It could also solve other issues.

You are right @Brachi is not easy to understand the reason of the crash without seeing the whole code. But it’s not easy to isolate it. Anyway, I’ll tried the fixes made on the add-on repository and I’ll let you know if it’s solved.
And yes, the Tissue version that I was updating is that one.

Ok, thanks to the documentation I’m now able to get the modified mesh without crashes. My problem now is different: getting a modified mesh, I lose informations about vertex groups. This code should be tested on a Cube with a subdivision surface and with all vertices in the vertex group:

import bpy
ob = bpy.context.object

# Depsgraph
depsgraph = bpy.context.evaluated_depsgraph_get()

# Get modified object
ob_eval = ob.evaluated_get(depsgraph)
new_ob = ob_eval.copy()
new_ob.data = ob_eval.to_mesh()

# Get weight for the first vertex

What I get is:
RuntimeError: Error: Vertex not in group

With the old code it worked, but apparently now I lose informations about weight. Am I missing something?

There’s a bug report about it:

Thanks I joined the converstation there.