1
$\begingroup$

This Script I wrote for remeshing purposes does not work properly. Sometimes it works. Sometimes it produces many (as many as frames) duplicates of the active Object.

import bpy

frame_end = bpy.context.scene.frame_end
sel_Objects = bpy.context.selected_objects

cuts = []

if(len(sel_Objects) == 2):

    for i in range(frame_end):

        bpy.context.scene.frame_set(i)

        bpy.ops.object.select_all(action='DESELECT')
        sel_Objects[0].select = True
        sel_Objects[1].select = True
        bpy.context.scene.objects.active = sel_Objects[0]

        bpy.ops.object.duplicate()
        bpy.ops.object.join()

        to_delete = bpy.context.scene.objects.active

        bpy.ops.object.editmode_toggle()
        bpy.ops.mesh.intersect(mode='SELECT', use_separate=True)
        bpy.ops.mesh.separate()
        bpy.ops.object.editmode_toggle()

        bpy.context.scene.objects.unlink(to_delete)
        bpy.data.objects.remove(to_delete)

        cuts.extend(bpy.context.selected_objects)


    bpy.ops.object.select_all(action='DESELECT')
    for cut in cuts:
        cut.select = True

    bpy.context.scene.objects.active = cuts[0]
    bpy.ops.object.join()

The script should performe the following actions:

  • Before you have two animated Objects intersecting each other while the animation. Before

  • After running the script you should still have the two animated Objects but also the intersections of the two objects merged into one mesh.

But this is how it looks like:

After

The problem @this point is that the script doesn't clear several duplicates of , in this case the torus.

$\endgroup$
  • 1
    $\begingroup$ You are using a lot of operators - could be an issue. What the script should do exactly? Error messages? Could you please provide a sample scene? $\endgroup$ – p2or Apr 21 '15 at 8:08
  • $\begingroup$ Agreed, please describe what the script is supposed to be doing, and add a small image of a representative scene so we can reproduce the scenario and adjust the code where possible. $\endgroup$ – zeffii Apr 21 '15 at 10:41
  • $\begingroup$ try with these lines cut = bpy.context.selected_objects[0] cut.animation_data_clear() cuts.extend(bpy.context.selected_objects) $\endgroup$ – Chebhou Apr 21 '15 at 13:15
  • 1
    $\begingroup$ @schwenk still having a problem ? $\endgroup$ – Chebhou Apr 22 '15 at 18:49

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.