Menu scripting help: Why are my Items are greyed out?

Recently someone was wondering about about a “Save Incremental” button or menu item in another thread. I know it’s just a few clicks as it is, but I have to agree that a simple one stop command to incrementally save you scene would be really nice.

So I’ve been poking around in the code a bit and was able to find the command that does the incremental save. It’s just “bpy.ops.file.filenum()”. After looking at some other code it seems like it should just be “file.filenum” in the menu code. So I was able to edit the pyhton code for the main file menu and add an entry for it:

        layout.operator_context = 'INVOKE_AREA'
        layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
        layout.operator_context = 'INVOKE_AREA'
        layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
        <i><b>layout.operator("file.filenum", text="Save Incremental", icon='PLUS' )</b></i>

I added this just under “Save Copy…”. The problem is that when I run the script, I can see the comment in the menu but it’s grayed. I have no idea why though. Maybe someone who knows more about menu scripting can shed some light on this?

Thanks so much!

the op is probably poll-failing. I guess it checks for a modal-running file selector, and maybe all it does it changing the filename. You could however call the save as operator with the next available number, you would basically have to re-create the logic for finding the next number in python

Hey CoDEmanX, Thanks for the quick reply. What is “poll-failing”?

See here: