Created
November 27, 2015 09:05
-
-
Save zeffii/f86254d1f03568a63fcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
class MeshAlignVerts(bpy.types.Operator): | |
bl_idname = "mesh.align_verts" | |
bl_label = "Align verts pos" | |
bl_options = {'REGISTER', 'UNDO'} | |
unlocked = bpy.props.BoolProperty() | |
def update_unlock(self, context): | |
self.unlocked = True | |
# update individual verts | |
def update_indiv_vert_pos(self,context): | |
mesh=bmesh.from_edit_mesh(context.object.data) | |
sel_verts = [] | |
for v in mesh.verts: | |
if v.select: | |
sel_verts.append(v) | |
# TODO: Add logic to move points along custom defined transform orientation | |
# bpy.context.space_data.transform_orientation = 'GLOBAL' | |
for v in sel_verts: | |
if self.chosen_axis == 'X': | |
v.co.x = self.x_pos | |
if self.chosen_axis == 'Y': | |
v.co.y = self.y_pos | |
if self.chosen_axis == 'Z': | |
v.co.z = self.z_pos | |
x_pos = bpy.props.FloatProperty(name="X",description="X axis",default=0.0, update=update_unlock) | |
y_pos = bpy.props.FloatProperty(name="Y",description="Y axis",default=0.0, update=update_unlock) | |
z_pos = bpy.props.FloatProperty(name="Z",description="Z axis",default=0.0, update=update_unlock) | |
chosen_axis = bpy.props.EnumProperty( | |
items=(('X','X','Align along X axis'),('Y','Y','Align along Y axis'),('Z','Z','Align along Z axis')), | |
name="Choose Axis", | |
update=update_unlock) | |
def execute(self,context): | |
print (self.chosen_axis) | |
if self.unlocked: | |
self.update_indiv_vert_pos(context) | |
print ("Executed script") | |
return {'FINISHED'} | |
def register(): | |
bpy.utils.register_class(MeshAlignVerts) | |
def unregister(): | |
bpy.utils.unregister_class(MeshAlignVerts) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment