[Solved] Can I Sort the Redo Operator Panel or Exclude Properties?

Hi, I have a script which adds some new lights with predefined properties, which you can adjust from the redo panel. I’d like to know if it’s possible to adjust the order in which they’re displayed.

I’m only defining three properties - Strength (Lumens or Irradiance), Color Temperature, and Use Nodes.

image

However, I’m also getting the Align to World, Location, and Rotation settings in the panel. Is it possible to remove those? I’d guess that it comes from creating a new object on line 69:

light_object = bpy.data.objects.new(name=light.name, object_data=light_data)

I also get the same result when using:

bpy.ops.object.light_add(type=light.lightType)

I’m setting the location via the script after adding the object, so they don’t do anything. If I can’t get rid of them, is there a way to reorganize and place them below the other three?

Thanks!

Operators can have a draw method. The layout defined in that method will show up in the redo panel.

def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False

        layout.prop(self, "strength")
        # etc.

Btw, the reason those settings show up in the redo panel is the AddObjectHelper. It looks like this:

class AddObjectHelper:
    def align_update_callback(self, _context):
        if self.align == 'WORLD':
            self.rotation.zero()

    align_items = (
        ('WORLD', "World", "Align the new object to the world"),
        ('VIEW', "View", "Align the new object to the view"),
        ('CURSOR', "3D Cursor", "Use the 3D cursor orientation for the new object")
    )
    align: EnumProperty(
        name="Align",
        items=align_items,
        default='WORLD',
        update=align_update_callback,
    )

    location: FloatVectorProperty(
        name="Location",
        subtype='TRANSLATION',
    )

    rotation: FloatVectorProperty(
        name="Rotation",
        subtype='EULER',
    )

    @classmethod
    def poll(cls, context):
        return context.scene.library is None

So if you don’t need those settings, better not to use the AddObjectHelper.

1 Like

Thank you @Symstract , that’s exactly what I was looking for! Much appreciated :slight_smile:

1 Like