0
$\begingroup$

I'm trying to lie a object on a surface for 3D printing it afterwards.

In other words, I want to find a way to automatically position a complex object the best way on a printing table. Here is a sample picture of an object:

Therefore my idea was to use the gravity aimation of blender:

ctx = bpy.context


obj = ctx.scene.objects.active
ob.select = True

bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS')
obj.location = (0,0,0)
bpy.ops.object.transform_apply(location=True, rotation=True, scale=False)

bpy.ops.rigidbody.object_add()
obj.rigid_body.type = 'ACTIVE'
mod_col = obj.modifiers.new('col', 'COLLISION')
bpy.ops.object.modifier_apply(apply_as='DATA', modifier='col')

plane = bpy.ops.mesh.primitive_plane_add(radius=(obj.dimensions[0]+obj.dimensions[1]), location=(0,0,(obj.dimensions[2]/(-2))-1))
plane = bpy.context.active_object
plane.name = 'Plane'
bpy.ops.rigidbody.object_add()
plane.rigid_body.type = 'PASSIVE'
mod_col = plane.modifiers.new('col', 'COLLISION')
bpy.ops.object.modifier_apply(apply_as='DATA', modifier='col')

ctx.scene.frame_start = 0
ctx.scene.frame_end = 250

bpy.data.scenes['Scene'].gravity[2] = -50
bpy.ops.screen.animation_play()


if scene.frame_current == 249:
    bpy.ops.screen.animation_cancel(restore_frame=False)

obj = ctx.scene.objects.active
bpy.ops.object.transform_apply(location=True, rotation=True, scale=False)
bpy.ops.object.visual_transform_apply()
bpy.ops.object.anim_transforms_to_deltas()
plane.select = True

bpy.ops.object.delete()

Till now the animation won't stop at the last frame.

Is there a better way to lie the object flat and if not, how can I stop the animation at the last frame?

$\endgroup$
3
  • $\begingroup$ De facto tool for something like this is shrinkwrap modifier, but I don't know how it'll work for your case. Can you provide screenshots for clarification of what your models look like and what you're trying to do? $\endgroup$
    – JakeD
    Nov 16 '16 at 17:27
  • $\begingroup$ Thanks for your reply, I uploaded a screenshot. How could I use the shrinkwrap modifier to do this? $\endgroup$
    – Basti
    Nov 17 '16 at 10:50
  • $\begingroup$ So you want it just want it snapped to the surface of another object? Have you looked at this? $\endgroup$
    – JakeD
    Nov 17 '16 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.