How would you print to the info if no object is selected (no active object), or grey out the buttons for a script that is operating on a mesh object? I understand you could run a
self.report({'INFO'}, 'No Object Selected!')
in a execute function, but I already have an execute function for my Operator which is running fine when an object is selected. Basically I either need a grayed out button when no object is selected, or an error report telling the user to select an object first. I believe this might be possible with a Poll, but I don't know how to write it to check for an active object or not and print error to info, etc.
print("No Object Selected", context.object.name)?? – Increality Jul 12 '20 at 18:21if context.object is not None: print("Hello", context.object.name) else: print("No Object Selected")– Sighthound Jul 12 '20 at 18:53if bpy.context.view_layer.objects.active: print("Hello", bpy.context.view_layer.objects.active.name) else: print("No object active"). Btw multiple objects might be selected, but only one object can be active. – Sighthound Jul 12 '20 at 19:13