Results 1 to 6 of 6

Thread: Deselect All Command

  1. #1

    Deselect All Command

    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.



  2. #2
    operators work normally on the active object only

    happy bl
    Nice 3D models = 25 % K.I.S.S + 25 % common sense + 25 % Inspiration + 25 % Knowledge
    Win 10 64 bits / Thanks and a Happy 2.79 with Cycles



  3. #3
    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.



  4. #4
    Well, after a bit of research, I found that this invoke() function, added to my operator class, accomplished what I needed:

    Code:
    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?



  5. #5
    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?



  6. #6
    If you are still following or someone comes here:
    Code:
    for ob in bpy.context.selected_objects:
        ob.select = False
    Also resort to Blender Stackexchange in the future, awesome website!



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •