2.8 add item to menu object?

is there a way to add a new item at bottom of object menu in edit mode

I need to quickly access the Add image plane for a background image in viewport !

I know how to use the addon for image plane
but need a faster way to add a background image in viewport

if not In object menu may be in the layout menu !

thanks
happy bl

You just need to know the name of the menu that you wish to put your item in…
Here’s an example on how to put a ‘label’ in the DOPESHEET_MT_context_menu.

i’m not really in anim and still learning things in 2.8

script run ok no errors
but don’t see where it is added !

where does the new panel appears ?

how do you get this dope sheet context menu like shown in other thread?

thanks
happy bl

The process hasn’t change in 2.8x, it’s still the same as in 2.7x.

You need to know in which menu do you want to place the call to your operator. It won’t be the DOPESHEET_MT_context_menu, which was just an example.
Check the /blender_path/2.8x/scripts/startup/bl_ui/space_view3d.py to see which menu do you want… Then append your function to it.
Your function should call the operator you want (with self.layout.operator)

will check new API but so many news things added and not backward compatible!
takes some time to get use to these new things

I check the template for add mesh object

and I can see an operator which open up a new window
in the operator I see only the scale property
but in the window panel I see all 3 - Loc Rot and scale vars!

why do we see all 3 when there is only one prop in the operator ?

thanks
happy bl

properties can be marked as hidden, among other things. when writing addons, it’s sometimes useful to have a serialized property that does not distract the user.

yes but in the operator definition I see only one prop for scale
not for rot or loc

so why do we see in the panel the 3 props - Rot Loc and Scale ?

thanks
happy bl

specifically, what operator are you talking about? what idname?

in the add mesh object template
inside 2.8 templates

thanks
happy bl

image
I see exactly what the code says I should see. which is this (width, height, depth, align, location, rotation- layers is hidden, as i mentioned above):

width: FloatProperty(
        name="Width",
        description="Box Width",
        min=0.01, max=100.0,
        default=1.0,
    )
    height: FloatProperty(
        name="Height",
        description="Box Height",
        min=0.01, max=100.0,
        default=1.0,
    )
    depth: FloatProperty(
        name="Depth",
        description="Box Depth",
        min=0.01, max=100.0,
        default=1.0,
    )
    layers: BoolVectorProperty(
        name="Layers",
        description="Object Layers",
        size=20,
        options={'HIDDEN', 'SKIP_SAVE'},
    )

    # generic transform props
    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=AddObjectHelper.align_update_callback,
    )
    location: FloatVectorProperty(
        name="Location",
        subtype='TRANSLATION',
    )
    rotation: FloatVectorProperty(
        name="Rotation",
        subtype='EULER',
    )

not that one
pick the first template at top
and look at the operator then look at the panel in viewport

thanks
happy bl

that comes from the object_data_add helper function- it initializes an object with commonly used options such as location, rotation, alignment type, etc.

https://docs.blender.org/api/current/bpy_extras.object_utils.html?highlight=object_data_add#bpy_extras.object_utils.object_data_add