1
$\begingroup$

I have a bunch of objects that I have converted into a DP canvas. The thing is that I have to activate manually all the outputs for that objects. I have created a small script but it's not working:

import bpy
dynamic = bpy.context.selected_objects
bpy.ops.object.select_all(action='DESELECT')
for i in dynamic:
    i.select = True
    bpy.ops.dpaint.output_toggle(output='A')
    i.select = False

PD: Works with on single object selected. But don´t know why it faill with a broader selection

$\endgroup$
2
$\begingroup$

Try this:

import bpy
dynamic = bpy.context.selected_objects[:]
bpy.ops.object.select_all(action='DESELECT')
for i in dynamic:
    i.select = True
    bpy.context.scene.objects.active = i
    bpy.ops.dpaint.output_toggle(output='A')
    i.select = False

The [:] bit at the end of line 2 creates a copy of the list instead of using a reference to the bpy.context.selected_objects, that might be affected by changes in the state of selection of the scene's objects.

The bpy.context.scene.objects.active = i makes each object active as well as selected. Many operators act on the active object only and ignore other selected objects.

$\endgroup$
  • $\begingroup$ I have tried but doesn´t work $\endgroup$ – Jorge Losilla Martínez Jan 26 '16 at 10:40
  • $\begingroup$ Sorry I was doing something wron. Worked perfectly $\endgroup$ – Jorge Losilla Martínez Jan 26 '16 at 10:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.