import json import os import unreal DEST_MAP = "/Game/MrPlow/Maps/VehicleImports/Lvl_KAMAZ_CR_SimpleVisual" MESH_PATH = "/Game/MrPlow/Vehicles/KAMAZ_CR/SM_KAMAZ_CR_BaseVisual.SM_KAMAZ_CR_BaseVisual" REPORT_PATH = r"C:\Users\post\Documents\mrPlow\mrPlow58\VehicleExports\KAMAZ_CR\unreal_kamaz_cr_simple_visual_level_report.json" def main(): result = {"ok": False, "map": DEST_MAP, "mesh": MESH_PATH} try: unreal.EditorLevelLibrary.new_level(DEST_MAP) mesh = unreal.EditorAssetLibrary.load_asset(MESH_PATH) cube = unreal.EditorAssetLibrary.load_asset("/Engine/BasicShapes/Cube.Cube") if not mesh: raise RuntimeError("Missing mesh asset: {}".format(MESH_PATH)) if cube: floor = unreal.EditorLevelLibrary.spawn_actor_from_object(cube, unreal.Vector(0, 0, -5), unreal.Rotator(0, 0, 0)) floor.set_actor_label("VERIFY_GroundPlane") floor.set_actor_scale3d(unreal.Vector(20.0, 20.0, 0.1)) actor = unreal.EditorLevelLibrary.spawn_actor_from_object(mesh, unreal.Vector(0.0, 0.0, 34.0), unreal.Rotator(0.0, 0.0, 0.0)) actor.set_actor_label("VERIFY_KAMAZ-53605-3950-48A5_BaseVisual") light = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.DirectionalLight, unreal.Vector(0, 0, 500), unreal.Rotator(-45, 0, 0)) light.set_actor_label("VERIFY_DirectionalLight") player_start = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.PlayerStart, unreal.Vector(-700, 0, 220), unreal.Rotator(0, 0, 0)) player_start.set_actor_label("VERIFY_PlayerStart") unreal.EditorLevelLibrary.save_current_level() unreal.EditorAssetLibrary.save_asset(DEST_MAP, only_if_is_dirty=False) result["ok"] = True result["actor"] = actor.get_path_name() except Exception as exc: result["error"] = str(exc) os.makedirs(os.path.dirname(REPORT_PATH), exist_ok=True) with open(REPORT_PATH, "w", encoding="utf-8") as report: json.dump(result, report, ensure_ascii=False, indent=2) unreal.log("KAMAZ_CR simple visual level report: {}".format(json.dumps(result, ensure_ascii=False))) main()