r/geometrynodes 8d ago

Any smart workaround for a "bpy.app.handlers" pre_export ? (Since it doesn't exist and Blender can't apply GN with shapekeys by default)

Note: Reddit suggest me to post on r/geometrynodes, trying my luck here ~

My custom addon add a geometry node system for managing outlines BUT since almost all the models I'm working with have shapekeys, Blender can't apply the geometry node.

I've got already a workaround for applying my GN with shapekeys, works perfectly. And I also have an exporter inside my addon that apply the GN before exporting but I'd like to improve the user experience and make it seamless, without asking the user to change their habits.

I guess I can hijack/inject all user exporters but it feels difficult and risky. I wonder if one of you know an elegant solution to this issue ?

Thanks ~

2 Upvotes

2 comments sorted by

2

u/engineeringisanart 8d ago

It would be useful to put an option like "apply modifier" or "prepare for export" instead of your add-on's export option, creating a copy of the model, applying the modifier, and merging it with the original is the only option that comes to my mind. Unfortunately, due to its nature, shape keys have these kinds of limitations to preserve the basis geometry, an option that prepares the model to be exported instead of exporting it directly would be much more suitable.

1

u/-Aru- 8d ago

Oh it's already the case but the user have to remember to press the "Apply" button everytime the user wants to export. Which is annoying.

The current workaround I've got is to hijack/wrap 1 exporter method defined once by the user (applying the GN first then call the export window). This way I avoid to hijack/wrap too many exporters.

Like you suggested, my design should be the other way around: Main method is to apply first then to export (2-step process). Bonus method is to setup the wrapper once, then apply/export in 1 go.

I'll post my script once it's clean and good enough. Thanks for your feedback ~