Results 1 to 1 of 1
  1. #1

    How to make this script to quickly set specific weights? (Screenshot attached)

    I have an idea how to get a faster workflow when assigning weights in edit mode, and would like to know how hard this would be to make in python as an addon:

    I'm manually setting weights using this method:
    1) Select one or more vertices
    2) Select a vertex group
    3) Choose a weight
    4) Click Assign

    If I'm not happy with it, repeat 3-4 until I'm happy. This can be quite cumbersome.

    With my addon, it would be one less step, like this:
    1) Select one or more vertices
    2) Select a vertex group
    3) Click 20 - And 0.2 is assigned in one click

    If I'm not happy with it, I just click another value. It would save a lot of time for me.

    And as an extra bonus, if this is possible, there is also a Liveweight slider, that updates the vertex group as I drag the slider, and I see the result right away. Pretty much like the Vertex weights in the Properties panel, but this affects all selected vertices.

    Would this be possible, and where would I start? I have never coded anything in python, but I've been coding for a long time, mostly PHP and Javascript, so I think I can figure out the basics, if I get some pointers.

    Also, is it possible to put this inside the Vertex Group section, or does it need to be in a separate panel? I've attached a rough screenshot of my idea as a separate panel.

    EDIT: After some fiddling, this is what I got, however the buttons are not showing up. Why?

    Also how do I assign weights to the current vertices in the selected group? I will study the documentation a bit more, but any help would be nice :)

    bl_info = {    "name": "Quickly set weights of Vertex Groups",
        "author": "nicmar",
        "version": (1, 0),
        "blender": (2, 78, 0),
        "location": "Properties Editor > Object data > Vertex Groups",
        "description": "Quickly set Vertex Groups with assigned weight and live edit",
        "warning": "",
        "wiki_url": "",
        "category": "Mesh"}
    import bpy
    from bpy.types import Panel
    class QuickWeightPanel(Panel):
        bl_label = "Quick Vertex Weights"
        bl_space_type = "PROPERTIES";
        bl_region_type = "WINDOW";
        bl_context = "data"
        def draw(self,context):
            layout = self.layout
            row = layout.row(align=True)
            row.alignment = 'EXPAND'
            row.operator("my.button", text="0").number=0
            row.operator("my.button", text="10").number=0.1
            row.operator("my.button", text="25").number=0.25
            row.operator("my.button", text="40").number=0.4
            row.operator("my.button", text="50").number=0.5
            row.operator("my.button", text="60").number=0.6
            row.operator("my.button", text="75").number=0.75
            row.operator("my.button", text="90").number=0.9
            row.operator("my.button", text="100").number=1
    def register():
    def unregister():
    if __name__ == "__main__":
    Attached Images Attached Images
    Last edited by nicmarxp; 17-Mar-17 at 04:20. Reason: Added code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts