デフォルトキューブを移動

対応バージョン

実行形式

Note

2.69

Pythonインタラクティブコンソール

デフォルトのCubeオブジェクトを移動させる

デフォルトで用意されている立方体オブジェクトを原点から移動させます。

実行してみましょう

Blender の Pythonインタラクティブコンソールから実行してみます。

まずはスクリーンの変更から。画面上部のアイコンをクリックして、出てきた選択肢から Scripting を選びましょう。

左下に PYTHON INTERACTIVE CONSOLE ... と書かれた黒地のエリアがあると思います。その中にマウスカーソルをポイントし、以下をそれぞれの行ごとに入力すると、 Cubeが(1,0,0)に配置されます。

a = D.objects.get('Cube')

a.location = ( 1,0,0 )

実行結果

>>> a = D.objects.get('Cube')

>>> a.location = ( 1,0,0 )

>>>

元の3Dビュー画面に戻したい

画面上部のアイコンをクリックして、出てきた選択肢から Default を選びましょう。

発展

では、3Dビュー上でエディットモードにてCubeオブジェクトをDuplicate [Shift]+[D]します。そのオブジェクト名は"Cube.001"のはずですね。では同様に、(-1,0,0)に移動させてみます。入力するところは">>>”のところですね。

>>> b = D.objects.get('Cube.001')

>>> b

bpy.data.objects['Cube.001']

>>> dir(b)

['__doc__', '__module__', '__qualname__', '__slots__', 'active_material', 'active_material_index', 'active_shape_key', 'active_shape_key_index', 'animation_data', 'animation_data_clear', 'animation_data_create', 'animation_visualization', 'bl_rna', 'bound_box', 'children', 'closest_point_on_mesh', 'collision', 'color', 'constraints', 'convert_space', 'copy', 'cycles_visibility', 'data', 'delta_location', 'delta_rotation_euler', 'delta_rotation_quaternion', 'delta_scale', 'dimensions', 'draw_bounds_type', 'draw_type', 'dupli_faces_scale', 'dupli_frames_end', 'dupli_frames_off', 'dupli_frames_on', 'dupli_frames_start', 'dupli_group', 'dupli_list', 'dupli_list_clear', 'dupli_list_create', 'dupli_type', 'empty_draw_size', 'empty_draw_type', 'empty_image_offset', 'field', 'find_armature', 'game', 'grease_pencil', 'hide', 'hide_render', 'hide_select', 'is_deform_modified', 'is_duplicator', 'is_library_indirect', 'is_modified', 'is_updated', 'is_updated_data', 'is_visible', 'layers', 'layers_local_view', 'library', 'location', 'lock_location', 'lock_rotation', 'lock_rotation_w', 'lock_rotations_4d', 'lock_scale', 'material_slots', 'matrix_basis', 'matrix_local', 'matrix_parent_inverse', 'matrix_world', 'mode', 'modifiers', 'motion_path', 'name', 'parent', 'parent_bone', 'parent_type', 'parent_vertices', 'particle_systems', 'pass_index', 'pose', 'pose_library', 'proxy', 'proxy_group', 'ray_cast', 'rigid_body', 'rigid_body_constraint', 'rna_type', 'rotation_axis_angle', 'rotation_euler', 'rotation_mode', 'rotation_quaternion', 'scale', 'select', 'shape_key_add', 'show_all_edges', 'show_axis', 'show_bounds', 'show_name', 'show_only_shape_key', 'show_texture_space', 'show_transparent', 'show_wire', 'show_x_ray', 'slow_parent_offset', 'soft_body', 'tag', 'to_mesh', 'track_axis', 'type', 'up_axis', 'update_from_editmode', 'update_tag', 'use_dupli_faces_scale', 'use_dupli_frames_speed', 'use_dupli_vertices_rotation', 'use_dynamic_topology_sculpting', 'use_extra_recalc_data', 'use_extra_recalc_object', 'use_fake_user', 'use_shape_key_edit_mode', 'use_slow_parent', 'user_clear', 'users', 'users_group', 'users_scene', 'vertex_groups']

>>> b.loc

ation

k_location

k_rotation

k_rotation_w

k_rotations_4d

k_scale

>>> b.location

Vector((2.9262561798095703, 3.8530101776123047, -0.41243454813957214))

>>> b.location = (-1,0,0)

>>> b.location

Vector((-1.0, 0.0, 0.0))

>>>