Delete All 3D Instances

Delete All 3D Instances
 1# This example removes all the 3d instances one-by-one in all the 3d layers in the active drawing.
 2
 3for layer in impact.active_drawing.layers:
 4    if layer.layer_type == "THREE_D":
 5        scene = layer.scene
 6
 7        if scene is not None:
 8            num_instances = scene.instances.count
 9
10            for n in range(1, num_instances  + 1):
11                index = (num_instances - n) + 1
12
13                if scene.instances.remove(index):
14                    impact.gui.output_toolbox.add("Instance removed with index: " + str(index))
15                else:
16                    impact.gui.output_toolbox.add("Instance not removed with index: " + str(index))
17
18        else:
19            impact.gui.output_toolbox.add("No 3d scene")