Part of this code should be outside if
block, currently selection changes only when hollow duplicate is created. It should change regardless of that, new object is added to the scene - it should be selected and active.
It's a lot, but after that it all done for the exception of one issue which we'll discuss later after UI part is handled.
Offset
If you find matrix stuff confusing, then you could write it as:
Again, you don't need to comment on every line, there is a check above if create_hollow
and you are using bpy.data.objects.new
right after it, the code is self-explanatory.
This code block is useless, just do if self.offset > 0.0
It's better to avoid negation, if possible, it just makes harder to follow the logic.
Duplicating operator settings in the scene is redundant, it is much better to invoke popup dialog with operator settings:
Do you have any more feedback/suggestions/comments about this part?
Tool execution is fine, now we need to tackle UI. I'll do it in a separate thread.
hollow object stay on the same position of the target object
Or alternatively strip world matrix of translation component.
mat = ob.matrix_world.copy()
mat.translation = 0, 0,…
What do you think about this approach?
Your approach is fine, the intent is not as clear with new_from_object
, but that is semantics, functionality is exactly the same.
mesh it produces…
Yeah, let's do Create Hollow Copy
instead.
I'm not getting what you mean by instantiate in bpy.data.meshes
, we still have to use obj.to_mesh()
to get evaluated mesh.
I'm not aware of native…
It's better to not create unnecessary local variables, especially when they are rarely used.
Ther should be "gate" conditions at the beginning of the execute method checking for invalid values.
Trailing whitespace and hard to read. Either do a newline for each attribute or keep it single line, it's not that long anyway.
What is happening here? If you need to convert to list just use newquads = list(newquads)
.
Code style
I really think that join feature is not good in this case, since we use evaluated mesh and original object could have a lot of modifiers, like Subd which will freeze/crash Blender if voxel density is too high.
That's unnecessary, just check if in edit mode in invoke
method and if true switch to object mode, switching back is not needed here.