Last active
August 7, 2018 03:59
-
-
Save tomol/9768be26f2f2f4a21775111b268af783 to your computer and use it in GitHub Desktop.
選択部分の中心からx座標のみを0にしたところに3Dカーソルを置いてくれるやつ
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 | |
bl_info = { | |
"name": "カーソルを選択物のX座標が0の位置へ", | |
"author": "orokanaMyMol", | |
"version": (1, 0), | |
"blender": (2, 79, 0), | |
"location": "オブジェクト > スナップ", | |
"description": "3Dカーソルを選択部分の中心座標から,X座標のみ0の位置に移す.", | |
"warning": "", | |
"support": "TESTING", | |
"wiki_url": "", | |
"tracker_url": "", | |
"category": "Tools" | |
} | |
class MoveCursor(bpy.types.Operator): | |
bl_idname = "tools.move_cursor" | |
bl_label = "カーソル → 選択物のX座標が0" | |
bl_description = "カーソルを選択したアイテムの中心に配置した後,x座標のみを0にします." | |
bl_options = {'REGISTER', 'UNDO'} | |
# メニューを実行した時に呼ばれる関数 | |
def execute(self, context): | |
# カーソル位置の変更 | |
bpy.ops.view3d.snap_cursor_to_selected() | |
bpy.context.scene.cursor_location.x = 0 | |
# ピポットポイントをカーソルに変更 | |
for area in bpy.context.screen.areas: | |
if area.type == 'VIEW_3D': | |
for space in area.spaces: | |
if space.type == 'VIEW_3D': | |
space.pivot_point = 'CURSOR' | |
return {'FINISHED'} | |
# メニューを構築する関数 | |
def menu_fn(self, context): | |
self.layout.separator() | |
self.layout.operator(MoveCursor.bl_idname) | |
# アドオン有効化時の処理 | |
def register(): | |
bpy.utils.register_module(__name__) | |
bpy.types.VIEW3D_MT_snap.append(menu_fn) | |
# アドオン無効化時の処理 | |
def unregister(): | |
bpy.types.VIEW3D_MT_snap.remove(menu_fn) | |
bpy.utils.unregister_module(__name__) | |
# メイン処理 | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment