終於完成 紀錄一下 import bpy def create_cube(width, height, depth): # 創建一個立方體 bpy.ops.mesh.primitive_cube_add(size=1) # 獲取剛創建的立方體對象 cube = bpy.context.active_object # 設置立方體的縮放比例 cube.scale = (width, depth, height) # 將立方體移動到原點 bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME', center='BOUNDS') # 更新場景 bpy.context.view_layer.update() # 清除場景中現有的對象 bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_by_type(type='MESH') bpy.ops.object.delete() # 使用者輸入長寬高 width = float(input("Enter width: ")) height = float(input("Enter height: ")) depth = float(input("Enter depth: ")) # 創建立方體 create_cube(width, height, depth)