A way to get User input as Variable?

HI there,
I am trying to make a little Script/Addon, that has a button in the N Panel,
and creates a vertexgroup from selected Vertices, and then renames it…

It looks a little like that…

class Assign2Vertexgroup(bpy.types.Operator):

bl_label = "Assign2Vertexgroup"
bl_idname = "assign.2_vertexgroup"
 

def execute(self, context):
   

    #######################################################################
    bpy.ops.object.vertex_group_assign_new()
    bpy.context.active_object.vertex_groups.active.name = "Align"
    bpy.ops.object.mode_set(mode='EDIT')
    return {'FINISHED'}
    #######################################################################

It works, but now I had the idea to not hardcode the “ALIGN” into that script, but to have a promptline in the panel were the user can predefine a name, that then is used for the renaming step…

is this possible in Blender/Python?

yes, there are multiple ways to do it. off the top of my head- you could write a property to the object or scene, then when the operator is run just access it from there.

HI testure,
what do you mean by Property?
do you mean a custom Property? How is this done?

Until now I wasnt able to have custom Properties (that i used with drivers) to show up in my Addon-Tab… but would be intetesting!

I am quite a beginner when it comes to python, so if you would have a bit more explanation/details then I would love to undestand :slight_smile:

Yes, custom properties. You can set them on bpy.types in the same way you set them as attributes in an operator class. If you haven’t read it yet I’d start with the official docs on basic addon creation.