Blender v2.72:使用光标作为旋转点将对象旋转到预定角度

时间:2015-01-28 00:31:13

标签: python blender autorotate

我正在尝试旋转圆圈,使用光标作为旋转点45度。光标不需要是旋转点,我只需要将对象旋转预定角度并围绕预定点。这是我的以下代码:

import bpy
from math import sin, cos, pi


def rotation():
    xlocation = 1
    ylocation = 1
    zlocation = 0

    bpy.ops.curve.primitive_bezier_circle_add(radius=.1, view_align=False, enter_editmode=False, location=(1, 1, 0), )

    bpy.ops.object.select_all(action='TOGGLE')
    bpy.ops.object.select_all(action='DESELECT')    
    bpy.ops.object.select_pattern(pattern = "BezierCircle*" ,case_sensitive = False, extend = False)
    bpy.context.scene.objects.active = bpy.data.objects["BezierCircle"]

    bpy.context.scene.cursor_location[0] = 3
    bpy.context.scene.cursor_location[1] = 1
    bpy.context.scene.cursor_location[2] = 0

    set_pivot_point('CURSOR')

    bpy.ops.transform.rotate( value=1.5708/2, axis=(-0, -0, -1), constraint_axis=(False, False, False), constraint_orientation='NORMAL', mirror=False, proportional='ENABLED', proportional_edit_falloff='SMOOTH', proportional_size=1.331, release_confirm=True)

    return ()

def set_pivot_point(type):

    if type not in ('BOUNDING_BOX_CENTER', 'CURSOR', 'INDIVIDUAL_ORIGINS','MEDIAN_POINT', 'ACTIVE_ELEMENT'):
        return False

    for a in bpy.context.screen.areas:
        if a.type == 'VIEW_3D':
            break
        else:
            return False

    a.spaces[0].pivot_point = type
    return True

rotation()     

0 个答案:

没有答案