I can start an operator with file selection by adding "INVOK_DEFAULT"
to it's call, e.g. bpy.ops.wm.alembic_import('INVOKE_DEFAULT')
(without it, it will raise an exception RuntimeError: Error: No filepath given
).
But how do I add code after this operator has finished? It would be needed to process just impored model without need for additional input from user. E.g. model is imported with bpy.ops.wm.obj_import()
and then I need to setup it's materials in a certain way.
Or before when file is already choosen? Can be useful since at this point we'll know the filepath
and can start importing any other related assets.
If we just add line after operator('INVOKE_DEFAULT')
it will be exeuted after file selection window appears, not after the operator has finished the execution:
import bpy
print('before invoke')
bpy.ops.wm.alembic_import('INVOKE_DEFAULT')
print('after wm.alembic_import invoke')
print('runs after file selection window was created')
PS I know that I can create new operator with file selection and call the operator with bpy.ops.wm.alembic_import(self.filepath)
like described here but I'm looking for more general solution - I don't want to mirror all operator's import properties in my operator, want to be able to call multiple INVOKE_DEFAULT
operators.
bpy.ops.import_mesh.stl
in mine operator and it doesn't allow calling multipleINVOKE_DEFAULT
operators one after another. $\endgroup$len(bpy.context.view_layer.objects.items())
?? $\endgroup$