This is a small set of tools to duplicate objects in different ways quick and easy.
The tools can be found under the object menu in the viewport.
This extension does not require special permissions.
This just seems to me like array but destructive (applied), but nothing against approving.
Some problems:
bpy.data.scenes["Scene"]
That is very very incorrect. It assumes that there is scene called "Scene". If user renames it, or works in another scene add-on will simply fail. Remove all instances of this and replace with context.scene
Additionally, add-on depends A LOT on uses of bpy.ops.
submodule, which is not recommended. Using ready-made operators with bpy.ops.
means that context should be same as ones that those operators need. If you have wrong context (wrong object mode, no active object, no selected objects, etc.) This will result in python errors thrown and operations cancelled midway.
It's recommended to research the bpy
and use lower-level API for those operations.
Operators can still be called from F3 menu in other modes when you have "developer extras" enabled. This is quite a edge case, but I want to give you one more round to learn about optimizing operators to avoid any python errors.
If I call operators that way from Edit mode I get errors and operators abort midway. Problem is switching modes inside operators isn't optimal, and needs lot of testing, because each use of "bpy.ops" expects certain mode, you need to know which mode is that, switch to that before using it, and do that for all of them, and restore original mode at the end. Not only is this just bad practice, but can really affect performance negatively.
Instead, use @classmethod def poll
to restrict operator to be used outside of context mode. For each operator you need something like this
@classmethod
def poll(cls, context):
return context.object and context.object.mode == 'OBJECT'
Implement those, test thoroughly to see you or I didn't make mistakes, and remove mode switching from inside the code.
I think it can be very valuable experience for you for future. And in general, in future by reducing uses of bpy.ops
and doing better coding can make your operators much faster and less prone to breaking.
Sign in to comment.
Ready for review