I'm a beginner in blender scripting, in How to place any object on the 'floor' of a scene?, @MACHIN3 wrote this simple but smart code. Can you explain me the meaning of every line?
import bpy
context = bpy.context
for obj in context.selected_objects:
mx = obj.matrix_world
minz = min((mx @ v.co)[2] for v in obj.data.vertices)
mx.translation.z -= minz
In the same question the topic of how can integrate this code in Blender as a button is very interesting, can you help me with this? Actually I'm working with tutorials, Manuals, etc. but I'm afraid my knowledge is not enough.
Text Editor > Templates > Python
Replace the innards ofmain(context)
with body of code above (ie the for loop) $\endgroup$