"Feature request", ...

The interface, modeling, 3d editing tools, import/export, feature requests, etc

Moderators: jesterKing, stiv

brasshat
Posts: 147
Joined: Mon Nov 16, 2009 1:06 pm

"Feature request", ...

Postby brasshat » Sun Jan 27, 2013 10:59 pm

...because I don't see these capabilities in Blender native functionality, though I admit that it may just be that I don't know where to look, or are there plug ins that would achieve what I want to do?

1) I'd like to be able to select two vertices, and see the distance between them.

2) I'd also like to be able to select a set if three or more vertices, and have Blender align them with to the first two vertices selected. I'd also like to see this work on sets of vertices, so that I could select three or more sets of vertices, and have the sets aligned.

ns

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Mon Jan 28, 2013 8:35 am

1.) here you go:

Code: Select all

import bpy, bmesh

class VIEW3D_OT_report_vert_distance(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "view3d.report_vert_distance"
    bl_label = "Report Vertex Distance"

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None and
                context.active_object.type == 'MESH' and
                context.active_object.mode == 'EDIT'
               )

    def execute(self, context):
        me = context.active_object.data
        bm = bmesh.from_edit_mesh(me)
       
        sel_verts = [v for v in bm.verts if v.select]
       
        if len(sel_verts) != 2:
            self.report({'WARNING'}, "Need 2 selected vertices!")
            return {'CANCELLED'}
       
        dist = (sel_verts[1].co - sel_verts[0].co).length
       
        self.report({'INFO'}, "Distance: %.02f" % dist)
        return {'FINISHED'}


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


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


if __name__ == "__main__":
    register()


2.) Did you try the LoopTools addon, it has a flatten feature?
I'm sitting, waiting, wishing, building Blender in superstition...

brasshat
Posts: 147
Joined: Mon Nov 16, 2009 1:06 pm

Postby brasshat » Mon Jan 28, 2013 11:03 am

I'm most appreciative of your efforts in providing the code, CoDEmanX, but I must confess that I lack the necessary knowledge and skills to add it to my installation of Blender, and I also would like to think that I'm not the only one who would find it of value, and that it might be considered for inclusion in future versions.

As to using the loop tools to accomplish my second request, I not sure I understand how using the loop tools add-on flatten feature would work in the situations for which I'm looking for the ability to align mesh elements.

ns

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Mon Jan 28, 2013 1:16 pm

there's deffo an addon for aligning things like you want it, and i believe looptools support it. But might be a different addon.

vert distance: i don't think that addon is any useful, the actual code is a single liner and it doesn't do anything else. Plus there might already be a better measure addon (i'm pretty sure there is...)

copy the code to a new text file and save as "view3d_report_vert_distance.py", then install addon with blender (easier than locating the copying to the addon folder). Then enable testing category in user prefs > addons, search for "report" or "distance" and enable the addon. In 3d View, hit space bar and type that phrase again to run it.
I'm sitting, waiting, wishing, building Blender in superstition...


Return to “Interface & Tools”

Who is online

Users browsing this forum: No registered users and 0 guests