user: Describe Advanced Rig Generation from the Blender manual or Python API, including usage steps and snippets.

assistant: ### Advanced Options Features

By using options in the Advanced sub-panel, it is possible to:

- Generate more than one rig per scene.
- Update/Override a specific rig.
- Force previously generated widget objects to be overwritten.
- Choose whether to use linked duplicates for left and right side widgets.
- Execute a script data-block after generation.

### Advanced Options Sub-Panel

[image reference removed]

Advanced rig generation options are by default hidden in a sub-panel. Click on the *Advanced* line to open it.

Some of the options will be automatically set by Rigify if they have no value when a rig is generated,
while others are fully controlled by the user.

Rig Name
:   When a brand new rig is generated, as opposed to overwriting an existing one, the value of this option
    is used to name it.

    If this field is empty, the new object will be named based on the name of the metarig according
    to the following rules:

    - If the name contains `META`, it is replaced with `RIG`.
    - If the name contains `metarig`, it is replaced with `rig`.
    - Otherwise, `RIG-` is prepended to the name.

    When overwriting an existing rig object specified by the *Target Rig* option, its name is not changed,
    allowing it to be freely renamed without having to keep the value of this option in sync.

Target Rig auto
:   This option specifies the generated rig to overwrite when re-generating from this metarig.

    If the option is not set, Rigify will generate a new rig object and store it in this option.

Rig UI Script auto
:   This option specifies the generated script data block to overwrite when re-generating, and
    works in the same manner as *Target Rig*.

    The script controls the UI in the 3D Viewport that allows conveniently switching visible
    bone collections, changing custom properties, converting between IK and FK and so on.

Widgets Collection auto
:   This reference specifies the collection containing generated widgets, and
    works in the same manner as *Target Rig*.

Overwrite Widget Meshes
:   If enabled, Rigify will generate new widgets every time the rig is re-generated. By default,
    it tries to reuse the already generated widget objects that exist in the widget collection,
    allowing them to be manually edited to fit the character better.

Mirror Widgets
:   When enabled, Rigify generates widgets for left and right side bones as
    linked duplicates, using negative X scale to flip the right side version.
    This enforces symmetry and reduces the number of meshes to adjust to
    fit the character.

    When reusing an already generated widget, Rigify detects if it was originally generated mirrored
    by checking object scale to avoid flipping existing controls. Therefore switching to mirrored
    widgets for an existing character requires deleting the right side widgets, or *Force Widget Update*.

Run Script
:   It is possible to configure Rigify to execute a Python script contained in a text data-block
    after generation in order to apply user-defined customizations. The script is executed with
    the generated rig active and selected in Object Mode.

    The simplest use of this may be adjusting properties of generated constraints when Rigify rig types
    don’t have any relevant meta-rig settings. That can be done by using the *Copy Full Data Path*
    context menu option on the property, pasting it into the script and making an assignment, e.g.:

    ```
    import bpy

    bpy.data.objects["rig"].pose.bones["MCH-spine.003"].constraints[0].influence = 0.6
    ```

    Doing such changes via a script ensures they aren’t lost if the rig is re-generated.

    Users familiar with [Rigify scripting](https://developer.blender.org/docs/features/animation/rigify/)
    can import Rigify utility modules, and access the generator instance through `rigify.get_generator()`.
    Yet note that, since generation is already finished, the only use of that is reading data created
    in the generation process.