連続辺をx軸の0で整列
ある程度分かってきたので、blender 2.58.1のaddon作って*1みる。
で何を作るかっていうと、
ModifierのMirrorで、以下のような鏡像との境界面の連続辺を、
こんな感じで、X軸の0に整列させたいこと*2があるので
それで行こうか。
で、以下bpyのコード。
import bpy def initialize(): global_undo = bpy.context.user_preferences.edit.use_global_undo bpy.context.user_preferences.edit.use_global_undo = False bpy.ops.object.mode_set(mode='OBJECT') return global_undo def terminate(global_undo): bpy.ops.object.mode_set(mode='EDIT') bpy.context.user_preferences.edit.use_global_undo = global_undo class AxisAlignUi(bpy.types.Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'TOOLS' bl_context = "mesh_edit" bl_label = "AxisAligh" def draw(self, context): layout = self.layout obj = context.object col = layout.column() col.label(text="Align Location:", icon='MAN_SCALE') col = layout.column_flow(align=True) col.operator("object.align_objects_scale_x",text="X_Axis") #col.operator("object.align_objects_scale_y",text="Y_Axis") #col.operator("object.align_objects_scale_z",text="Z_Axis") ## Axis Align ScaleX class AlignScaleXOperator(bpy.types.Operator): bl_idname = "object.align_objects_scale_x" bl_label = "Align Selected Scale X To Active" @classmethod def poll(cls, context): ob = context.active_object return (ob and ob.type == 'MESH' and context.mode == 'EDIT_MESH') def execute(self, context): zeroScaleX(context) return {'FINISHED'} def zeroScaleX(context): bpy.ops.transform.resize(value=(0,1,1)) #<= s-x-0 global_undo = initialize() mesh = bpy.context.active_object.data verts = [v for v in mesh.vertices if v.select and not v.hide] lot_x = verts[0].co[0] terminate(global_undo) bpy.ops.transform.translate(value=(-lot_x,0,0)) #<= move to x-axis of 0 ## registring def register(): #bpy.utils.register_class(AxisAlignUi) bpy.utils.register_module(__name__) def unregister(): #bpy.utils.unregister_class(AxisAlignUi) bpy.utils.unregister_module(__name__) if __name__ == "__main__": register()