0
$\begingroup$

I use blender for 3d printing and often want to move vertices or extrude faces to a particular point.

For example

I have a face at the y coordinate 3.47. After selecting that face I often find I would like to extrude it in the y axis to position 5.0. Is there a way to specify the position instead of the amount you want to move ?

Currently I calculate the difference manually in a calculator and the extrude by that amount.

Is there an easier way. I guess I could create a Python extension for it but wanted to make sure it didn't exist.

Thanks

$\endgroup$
  • $\begingroup$ right after extruding (E) you're automatically in grab mode. So, you could undo that grab (ESC) and in the properties panel (N) set the desired (median) position of your face... $\endgroup$ – m.ardito Jan 22 '17 at 10:31
0
$\begingroup$

I couldn't get m.ardito answer to work. I wanted to move vertices with different y position to all the same plane. I found lots of answers on forums with answers like

"select the vertices and press S Z 0 to put all the vertices in the same z-position, then move then set the 'Median Z' value in the transform properties."

I just could not get these to work.

In the end I modified a the script I found.

import bpy
import mathutils


class OBJECT_OT_MoveX(bpy.types.Operator):
    """Move selected vertices to cursor's location"""
    bl_idname = "object.movex_operator"
    bl_label = "Simple Move Operator"

    @classmethod
    def poll(self, context):
        return context.mode == 'EDIT_MESH'

    def execute(self, context):
        MoveSelectedVerticesToCursor(True, False, False)
        return {'FINISHED'}

class OBJECT_OT_MoveY(bpy.types.Operator):
    """Move selected vertices to cursor's location"""
    bl_idname = "object.movey_operator"
    bl_label = "Simple Move Operator"

    @classmethod
    def poll(self, context):
        return context.mode == 'EDIT_MESH'

    def execute(self, context):
        MoveSelectedVerticesToCursor(False, True, False)
        return {'FINISHED'}

class OBJECT_OT_MoveZ(bpy.types.Operator):
    """Move selected vertices to cursor's location"""
    bl_idname = "object.movez_operator"
    bl_label = "Simple Move Operator"

    @classmethod
    def poll(self, context):
        return context.mode == 'EDIT_MESH'

    def execute(self, context):
        MoveSelectedVerticesToCursor(False, False, True)
        return {'FINISHED'}



def MoveSelectedVerticesToCursor(moveX, moveY, moveZ):
    bpy.ops.object.mode_set(mode='OBJECT')

    for vertex in bpy.context.object.data.vertices:
        if vertex.select:
            new_location = https://blenderartists.org/forum/showthread.php?280330-XYZ-location-of-Verticesbpy.context.object.matrix_world.inverted()*bpy.context.scene.cursor_location 
            if moveX:
                vertex.co[0] = new_location[0]
            if moveY:
                vertex.co[1] = new_location[1]
            if moveZ:
                vertex.co[2] = new_location[2]

    bpy.ops.object.mode_set(mode='EDIT') 

class MyPanel(bpy.types.Panel):
    bl_idname = "OBJECT_PT_my_panel"
    bl_label = "Align to Cursor"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    #bl_context = "object"

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        col = row.column()
        view = context.space_data
        col.prop(view, "cursor_location", text="3D Cursor Location")
        #row.prop(bpy.context.object, "OBJECT_OT_delete", text = "Cursor to selected")

        layout.row()
        layout.label(text="Align selected vertices to cursor position", icon='MESH_DATA')
        row = layout.row(align = True)

        row.operator(OBJECT_OT_MoveX.bl_idname, text="X")
        row.operator(OBJECT_OT_MoveY.bl_idname, text="Y")
        row.operator(OBJECT_OT_MoveZ.bl_idname, text="Z")

def register():
    bpy.utils.register_class(MyPanel)
    bpy.utils.register_class(OBJECT_OT_MoveX)
    bpy.utils.register_class(OBJECT_OT_MoveY)
    bpy.utils.register_class(OBJECT_OT_MoveZ)


def unregister():
    bpy.utils.unregister_class(MyPanel)
    bpy.utils.unregister_class(OBJECT_OT_MoveX)
    bpy.utils.unregister_class(OBJECT_OT_MoveY)
    bpy.utils.unregister_class(OBJECT_OT_MoveZ)

if __name__ == "__main__":
    register()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.