Shrink/Fatten "Offset Even" can not be used as default
Open, ConfirmedPublic

Description

The "Offset Even" option is turned on by default for the Shrink/Fatten (Alt-S) tool. You can see this by opening user preferences, selecting the input tab and opening the Shrink/Fatten menu under the Mesh menu. However, if you use the tool, you'll see checking or unchecking this default option makes no difference. The tool always defaults to off.

It doesn't seem currently possible, even with custom coding, to have this option on by default. I disabled all transform modal map keys just to be sure they weren't interfering. They are not. I also tried changing the default key to something else (Ctrl-K). It seems nothing can be done to have this tool use "Offset Even" (i.e. even thickness) by default.

Details

Type
Bug
Philipp Oeser (lichtwerk) triaged this task as Confirmed priority.Apr 20 2018, 3:47 PM
Philipp Oeser (lichtwerk) claimed this task.

Confirming on first sight, but need to have a closer look later

See here and note that it finds the property, but RNA_property_is_set is not True [it is on redo though]. Like I said: will have a closer look later (and maybe pass on to @Campbell Barton (campbellbarton) if that doesnt succeed)

OK, so did a bit more reading code here.
Sorry if this blathering is a bit of a detour, but I'm keeping this as a reference (for myself, but maybe for others as well...)
And: please correct me if I'm wrong!

Regarding my last comment (RNA_property_is_set is not True):
Seems like operator properties start off being an PROP_IDPROPERTY (not a DNA one) and are flagged IDP_FLAG_GHOST
This happens when you do RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness");
If a property is flagged IDP_FLAG_GHOST the property is set but RNA will return false when checking RNA_property_is_set().
This way code can distigush between defaults and something that was explicitly set.
When redoing an operator the properties wont be flagged IDP_FLAG_GHOST anymore (because they have all been explicitly set)
So whenever you call RNA_boolean_set(), it will most likely end up in rna_idproperty_touch which unsets IDP_FLAG_GHOST.
If we wanted the keymap to actually have an effect in initTransInfo, we would simply have to do something like D3388

But more problems arise with above diff
So initTransInfo would go fine (it would pick up the prop and set transform flag accordingly)
But now comes transformEvent (called from transform_modal).
This toggles the transform flag according to pressing S (defined in transform modal keymap) or pressing/releasing ALT (hardcoded).
So releasing ALT will set Offset Even to OFF.
If you invoke the tool with ALT+S then you probably release the keys shortly after. Hm. This was not a problem before D3388 (it was OFF anyways), but now it will be.
So as long as you hold the ALT key, D3388 should work.
We could of course disable ALT for Shrink/Fatten (see P688), or move to other keys? (Note this will unfortunately need update in translations, because of header text...)

What about 2.8?
This should still aplly there, too right?

@Campbell Barton (campbellbarton) : any thoughts?

If it means anything, my main concern with this as an addon developer is being able to use the functionality of even offset fat/shrinking within custom modal operators. The fact that there is currently no way to invoke even offset fat/shrinking kills the potential of more useful tools (without having to result to emulating this operator via custom coding adding significant unnecessary overhead). Probably on a larger scale, modal operators should follow a protocol where-in this kind of thing could not become an issue.

@sicutunum : wasnt aware this is about usage from python as well...

from python you can actually invoke it like this, no?
bpy.ops.transform.shrink_fatten('INVOKE_DEFAULT', use_even_offset=True)

So quickly putting this into a custom modal op like this seems to do it (unless I am misunderstanding something...)

import bpy

class ModalOperator(bpy.types.Operator):
    """Move an object with the mouse, example"""
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

    def modal(self, context, event):

        if event.type == 'LEFTMOUSE':
            bpy.ops.transform.shrink_fatten('INVOKE_DEFAULT', use_even_offset=True)
            return {'FINISHED'}

        elif event.type in {'RIGHTMOUSE', 'ESC'}:
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.object and context.object.mode == 'EDIT':
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "No active object in editmode, could not finish")
            return {'CANCELLED'}

def register():
    bpy.utils.register_class(ModalOperator)

def unregister():
    bpy.utils.unregister_class(ModalOperator)

if __name__ == "__main__":
    register()

Keymap is for invoking the tool via... well keys, that's not defining the default for python behavior to my knowledge.
If you wanted to pick this preference up from python you could also get it with the following I think:
bpy.context.window_manager.keyconfigs.default.keymaps['Mesh'].keymap_items['transform.shrink_fatten'].properties.use_even_offset

Hope this helps

@Philipp Oeser (lichtwerk) Hi. This is strange. I reported this bug because similar code I was using wasn't allowing for even offset. I was invoking it and using the same option as your code above and it kept defaulting to off. It's working now. Not sure why. Thanks though. I'm confused about your statement above "So as long as you hold the ALT key should work". This doesn't seem to be the case. It's always off even if I never release the Alt or S keys. Actually if I release Alt and keep holding S the option starts rapidly blinking. As far as there needing to be a protocol for this sort of thing, what I meant was that all 3D View modal operators released from blender.org should use mappable modal keymaps like with translate. There shouldn't be any 3D View modal operators (official ones from blender.org) that have any hard coded modifiers such as "Alt". Is there some reason they should?

I'm confused about your statement above "So as long as you hold the ALT key should work". This doesn't seem to be the case. It's always off even if I never release the Alt.

That's relevant only with the D3388 patch applied to the current code. Have you tried the patch?

Actually if I release Alt and keep holding S the option starts rapidly blinking

yep, thats expected. ALT is enabling temporarily (while keeping pressed), S toggles (all the time)

There shouldn't be any 3D View modal operators (official ones from blender.org) that have any hard coded modifiers such as "Alt". Is there some reason they should?

Havent checked that in depth, I guess some modifierskeys just havent been converted from ancient past (but there might be reasons these are still hardcoded which I havent investigated yet)