1

When I import a stl object it arrived like this (front view):

enter image description here

I have to manually rotate it until I have the two lower points of my object at the same level on the Z axis(that's what the black line is supposed to show). Here is the result after the first rotation, in the front view: enter image description here

The same rotation seen in the right view: enter image description here

Then I rotate it in the right view until the two extemum points of the object are at the same level on the Z axis:

enter image description here

Finally, I translate the object on the Z axis until every vertex of the object are above the XY plan : enter image description here

My question : How to do that with a python script ?

I thought about the least square method to correctly rotate the object but I don't know if it is the easiest way !


update That's what I obtain with the Bounding box :

enter image description here


update here's what I get with the convex hull : front view: enter image description here right view: enter image description here

reflyon
  • 129
  • 1
  • 11
  • 1
    Simplest way would be to use the dimensions of the object's bounding box. See this answer: http://blender.stackexchange.com/questions/5371/exporting-bullet-collision-shapes/6131#6131 – p2or Mar 24 '15 at 13:17
  • I just try and it didn't work ! The box created doesn't contain all the object (some parts of the object are out of the box) furthermore the object have no rotation (0°,0°,0°), so the box is not inclined. – reflyon Mar 24 '15 at 13:41
  • Could you share your code with us? – p2or Mar 24 '15 at 13:42
  • @poor the bounding box will not have the right orientation, blender doesn't have minimum BBOX ,best choice would be the convex hull – Chebhou Mar 24 '15 at 13:44
  • I didn't use a python script to create the box. Is it possible to send a printscreen in a comment ? – reflyon Mar 24 '15 at 13:45
  • @Chebhou You are right, but also part of gandalfs answer. – p2or Mar 24 '15 at 13:47
  • To create a convex hull from the mesh there is an operator: bpy.ops.mesh.convex_hull(), http://www.blender.org/api/blender_python_api_2_63_12/bpy.ops.mesh.html?highlight=hull#bpy.ops.mesh.convex_hull. Duplicate your object, toggle into Edit Mode and run the code. Also for bmesh: http://www.blender.org/api/blender_python_api_2_73_2/bmesh.ops.html?highlight=bmesh.ops.convex_hull#bmesh.ops.convex_hull – p2or Mar 24 '15 at 14:04
  • How can I use the convex hull to correctly move my object ? – reflyon Mar 25 '15 at 08:44

0 Answers0