0
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ Sorry, the format`s code is wrong $\endgroup$
    – flobo02
    May 25 '20 at 1:45
  • $\begingroup$ blender.stackexchange.com/questions/22888/… $\endgroup$
    – flobo02
    May 25 '20 at 1:48
  • 3
    $\begingroup$ Hi. If someone wrote the code in another question you should comment on the answer and ask them to explain it there. Also, please only ask one question at a time. Thanks. $\endgroup$ May 25 '20 at 2:07
  • 1
    $\begingroup$ Finds the minimum global coordinate of all vertices, translate the matrix such that this is on global z = 0. Look at the simple operator template in Text Editor > Templates > Python Replace the innards of main(context) with body of code above (ie the for loop) $\endgroup$
    – batFINGER
    May 25 '20 at 8:51
  • $\begingroup$ @batFINGER thank you very much for your help $\endgroup$
    – flobo02
    May 25 '20 at 14:46
0
$\begingroup$

My answer in

[1]How to place any object on the 'floor' of a scene?

My addon append one item in Object>Snap menu

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.