Displaying modifiers' warnings in a custom UI layout

Hello!

I’ve made an addon which has a custom UI for modifiers and I’d like to show the same warnings in the custom layout as are shown in the regular one.

Some warnings I can, more or less, implement myself going through the source code and writing the warning checks in Python. However, for example, the warning shown in the image is impossible(?) to achieve because I would need to know the vertex count after the Subdivision Surface modifier which I don’t think is possible.

Any suggestions? I assume this is not possible but it doesn’t hurt to ask…

That “error” data is stored in the ModifierData struct in the C code. Some of the elements of that struct are exposed to the RNA system but the “error” string isn’t. I think it would be a pretty trivial change in the C code but I’m not familiar with the design in this area to be confident that it should be.

If I need a break and have some free time I can make a patch for it though.

OK, thanks for you answer! I’ll move onto other features for now.

https://developer.blender.org/diffusion/B/browse/master/source/blender/modifiers/intern/MOD_datatransfer.c$149

Afaics the warning is triggered if either the resulting mesh or the input mesh is higher than 10k verts.

You can somewhat recreate this with something like this:

ob = bpy.context.object
dg = bpy.context.view_layer.depsgraph

if len(ob.evaluated_get(dg).data.vertices) > 10000:
    # display high-poly warning
    pass

It’s a bit more complex actually. In the image the subdiv modifier is causing the vertex count to go above 10 000. But if I would move the subdiv modifier after the Data Transfer modifier, the warning wouldn’t be shown. So only the modifiers before the Data Transfer are taken into account.

Thanks for the answer anyway.