{"id":12573,"date":"2026-09-29T19:26:12","date_gmt":"2026-09-30T00:26:12","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=12573"},"modified":"2026-09-29T19:26:12","modified_gmt":"2026-09-30T00:26:12","slug":"blender-script-moving-object","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=12573","title":{"rendered":"Blender Script: Moving Object"},"content":{"rendered":"<p>This script moves the selected object to be centered on the world origin\u00a0<em>but<\/em> it sits on the z plane rather than half of it being below the z plane.<\/p>\n<p>&nbsp;<\/p>\n<pre>import bpy\r\nfrom mathutils import Vector\r\n\r\n# Put the origin at the center of volume\r\nbpy.ops.object.origin_set(\r\ntype='ORIGIN_CENTER_OF_VOLUME',\r\ncenter='MEDIAN',\r\n)\r\n\r\nfor obj in bpy.context.selected_objects:\r\n# The bounding-box corners are stored in object-local coordinates.\r\n# Transform them to world coordinates before finding the lowest point.\r\nlowest_z = min(\r\n(obj.matrix_world @ Vector(corner)).z\r\nfor corner in obj.bound_box\r\n)\r\n\r\nworld_matrix = obj.matrix_world.copy()\r\nworld_matrix.translation.x = 0.0\r\nworld_matrix.translation.y = 0.0\r\nworld_matrix.translation.z -= lowest_z\r\nobj.matrix_world = world_matrix<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This script moves the selected object to be centered on the world origin\u00a0but it sits on the z plane rather than half of it being below the z plane. &nbsp; import bpy from mathutils import Vector # Put the origin at the center of volume bpy.ops.object.origin_set( type=&#8217;ORIGIN_CENTER_OF_VOLUME&#8217;, center=&#8217;MEDIAN&#8217;, ) for obj in bpy.context.selected_objects: # The &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2163],"tags":[2158,664],"class_list":["post-12573","post","type-post","status-publish","format-standard","hentry","category-blender-3d-printing","tag-blender","tag-python"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12573"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12573\/revisions"}],"predecessor-version":[{"id":12574,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/12573\/revisions\/12574"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}