프로그램 사용/Blender2026. 7. 14. 11:40

구글 ai 님께서 말씀하시길 metric이면 m 단위라고 하신다.

import bpy

# Get reference to the active object
obj = bpy.context.active_object

# Read the current location (returns a Vector of X, Y, Z in meters)
print(obj.location)

# Set location using standard meters (X=1m, Y=2m, Z=3m)
obj.location = (1.0, 2.0, 3.0)

# Modify a single axis (e.g., set X to 5 meters)
obj.location.x = 5.0

[링크 : https://docs.blender.org/api/current/bpy.types.UnitSettings.html]

 

blend 파일에서 meters 라고 되어있고 중앙의 소방관 모델과

6.5 칸 정도이고, 소방관은 1.8m 정도 키인것 같다.

 

x는 좌우로 5m 까지 이동

y는 -4m 로 고정(현재보다 앞으로 2.5m 이동)

z는 1~5m 높이로 이동 하도록 해서 했더니

import bpy
import random
import os

# -------------------------
# 설정
# -------------------------
NUM_IMAGES = 200

cube = bpy.data.objects["Node_1"]
light = bpy.data.objects["Spot"]

scene = bpy.context.scene

scene.render.engine = 'BLENDER_EEVEE'
scene.render.resolution_x = 640
scene.render.resolution_y = 480
scene.render.resolution_percentage = 100

# 저장 폴더 (blend 파일 기준)
output_dir = bpy.path.abspath("//render_output")
os.makedirs(output_dir, exist_ok=True)

# PNG 저장
scene.render.image_settings.file_format = 'PNG'

# -------------------------
# 렌더링 루프
# -------------------------
for i in range(NUM_IMAGES):
    # Cube 랜덤 이동
    cube.location.x = random.uniform(-2.0, 2.0)
    cube.location.y = random.uniform(-2.0, 2.0)
    cube.location.z = random.uniform(0.0, 0.0)
    # Spot Light 랜덤 이동
    light.location.x = random.uniform(-5.0, 5.0)
    light.location.y = random.uniform(-4.0, -4.0)
    light.location.z = random.uniform(1.0, 5.0)
    # 렌더 저장 경로
    scene.render.filepath = os.path.join(output_dir, f"image_{i:03d}.png")
    print(f"Rendering {scene.render.filepath}")
    bpy.ops.render.render(write_still=True)

print("Done.")

 

대충 의도한 대로 나와주긴 하는 듯?

'프로그램 사용 > Blender' 카테고리의 다른 글

blender bpy armatrue / metarig  (0) 2026.07.14
blender render / sample  (0) 2026.07.14
blender animation (keyframe)  (0) 2026.07.13
bpy built on module on blender  (0) 2026.07.13
blender constraint "track to "  (0) 2026.07.13
Posted by 구차니