I recently started to learn Python and I’m trying to wrap my head around the API. As far as I know, I can’t write my own modifier, so I’d like to make a regular addon, that simply behaves in a non-destructive way.
I want my addon to duplicate the active object (A), which can also be modified in edit mode, and process the duplicate (B) using a bunch of operators. The results of these operations would depend on some parameters available from the addon panel. Each change of any of these parameters would cause the duplicate (B) to be destroyed and again the source model (A) would get duplicated. The duplicate would again receive all the operations. Also, to make it more intuitive, the source (A) would have only wireframe displayed, so the processed model (B) is visable beneath.
So now that you know the case:
- First of all, does this approach make any sense?
- If yes, then what is the correct way to process the duplicate? As far as I know, I can’t really pass references to objects around and I probably can’t use operators on a non-selected object. Does it mean that I should make the addon:
a) switch to object mode if edit mode is on,
b) select duplicate (B),
c) switch to edit mode,
d) apply my operators (eg. bevels),
e) switch back to object mode,
f) bring back the original (A) selection,
g) switch to edit mode, if edit mode was originally on
every time? This looks more like a macro, than an addon, so I have a feeling that it can be done differently. Am I correct?