1
$\begingroup$

I'm getting this error and am not quite sure how to fix it

enter image description here

Please see below for my code....

def execute(self, context):
    for obj in bpy.context.selected_objects:
        charlen = 15
        namestore_1 = obj.name[:charlen]
        bpy.context.scene.objects.active = obj
        for ob in bpy.context.scene.objects:
            namestore_2 = ob.name[:charlen]
            if ob.type == 'MESH':
                if str(namestore_1) == (namestore_2):
                    ob.select = True
                else:
                    ob.select = False
    for selected in bpy.context.selected_objects:
        if selected.type == 'MESH':
            bpy.ops.object.join()

Thanks in advance for any help :) this ones been bugging me for a while!

[edit - updated code slightly for variable in place of number where the character lenght is involved]

$\endgroup$
  • 1
    $\begingroup$ I think you're messing up with the "selected_objects" when you start de-selecting objects in your nested loop. What are you trying to achieve here? Perhaps if you describe the logic of what you're aiming for, we can find the right algorithm to achieve it. $\endgroup$ – TLousky Jul 24 '17 at 14:33
  • $\begingroup$ Hi,Thanks very much for your response. Im trying to make addon that automatically joins objects of similar names. (i.e. all glass objects in the scene) for a few reasons. Most important of which is that it means that materials are easier to work with (in my case). So the process is as follows, user clicks on the object, then hits the button and all the objects with similar names are selected and joined. I should have mentioned that currently the addon does it's job - but the error message keeps coming up anyway! I just wanted to get rid of the error message really. $\endgroup$ – dood Jul 25 '17 at 2:27
1
$\begingroup$

An operator's execute(), invoke() or modal() methods must return a status as a set(). Also note that the return result must be one of {'RUNNING_MODAL', 'CANCELLED', 'FINISHED', 'PASS_THROUGH', ‘INTERFACE’}

The shortcut to creating a set is to wrap the item in curly braces {}.

def execute(self, context):
    # do stuff
    return {'FINISHED'}
$\endgroup$
  • $\begingroup$ Hi, Thanks for your reply. See the above comment for a more detailed explanation of my end goal if that helps. I'll try adding this to the end of my script this evening and see if it helps! thanks! $\endgroup$ – dood Jul 25 '17 at 2:33
  • $\begingroup$ @dood The error is incompatible return value which is because you don't return a result (at least not in the code you shared). You could also do return bpy.ops.object.join() $\endgroup$ – sambler Jul 25 '17 at 10:27

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.