Hey All. I have written an operator that creates a custom object and makes it the active object. It creates the object just fine. However, when I create a second object with that operator, the first object remains selected (though it is no longer the active object). Other operators automatically deselect all other objects. I want mine to do the same. Is there a parameter that I need to add to one of the functions? Or, do I need to use an “invoke()” function? What command do I need, to “deselect all”? Thanks.
operators work normally on the active object only
Yes, but my python-made operator is not deselecting the previous active object. The newly created object becomes active (bright orange outline) while the previous object somehow remains selected (dark orange outline). When creating that operator, did I miss a step? Thanks Ricky.
Well, after a bit of research, I found that this invoke() function, added to my operator class, accomplished what I needed:
def invoke(self,context,event): bpy.ops.object.select_all(action='DESELECT') return self.execute(context)
Still, I have to wonder, is this the “right way” or the “best way” to do this?
Well, I take it back—I spoke too soon. Now, when I activate my custom operator, the new object is active, and all others are deselected. However, as soon as I use the operator panel, to modify my object, the previous active object again becomes selected, though not active (dark orange outline).
To fix this, I had to move the command: bpy.ops.object.select_all(action=‘DESELECT’) to the first line of my execute() function, so that it runs every time the execute() loop is cycled. Again, is this the “right” or “best” way to do this?
If you are still following or someone comes here:
for ob in bpy.context.selected_objects: ob.select = False
Also resort to Blender Stackexchange in the future, awesome website!