I Stuck in creating a landscape heightmap Import macro. Plz Help. C++ Editor Scripting.

Hey everyone,
I am trying to import a Heightmap and Weightmaps to Update Landscape with Unreal Editor script.
Cuz I reimport those maps a lot, And I’d like to skip the step of setting filepath to Landscap ImportUI every time. So, I Looked up “LandscapeEditor/Private/LandscapeEdMode.cpp” And try to work my code. It’s not Realtime. I just need run it for Editor.

Well, My problem is I Read HeightData from the file right, and I set HeightData with “FHeightmapAccessor” to the Landscap, But nothing had changed. There is no Error, And even LandscapeStremingProxies actors are get modify marks as well. but no changed. I think I skipped some important step that necessary.

Someone Plz tell me what I’m missing.
I Put my Code I’m working on Blow.
Thanks.

void UMyUnrealPlugInsBPLibrary::ImportLandscapeHeightmap(ALandscape* Landscape, FString Path)
{

auto ActualPath = Path.IsEmpty() ? Landscape->ReimportHeightmapFilePath : Path;
ULandscapeInfo* LandscapeInfo = Landscape->GetLandscapeInfo();
auto LandscapeSize = Landscape->GetLoadedBounds();	
int32 NumSamplesX = (LandscapeSize.GetSize().X * 0.01) + 1;
int32 NumSamplesY = (LandscapeSize.GetSize().Y * 0.01) + 1;

TArray<uint16> HeightData;
ReadHeightmapFile(HeightData, *ActualPath, NumSamplesX, NumSamplesY);
if (NumSamplesX * NumSamplesY != HeightData.Num())
{
	UE_LOG(LogTemp, Warning, TEXT("Invalid Heightmap data."));
}else
{
	UE_LOG(LogTemp, Warning, TEXT("Import %s Heightmap Data Loaded."), *ActualPath);
}

int32 MinX, MinY, MaxX, MaxY;
LandscapeInfo->GetLandscapeExtent(MinX, MinY, MaxX, MaxY);

Landscape->RequestLayersContentUpdate(ELandscapeLayerUpdateMode::Update_Heightmap_All);
FHeightmapAccessor<false> HeightmapAccessor(LandscapeInfo);
HeightmapAccessor.SetData(MinX, MinY, MaxX, MaxY, (uint16*)HeightData.GetData());
Landscape->PostEditChange();
return;

}

bool UMyUnrealPlugInsBPLibrary::ReadHeightmapFile(TArray& Result, const FString& Filename, int32 ExpectedWidth, int32 ExpectedHeight)
{

bool bResult = true;
ILandscapeEditorModule& LandscapeEditorModule = FModuleManager::GetModuleChecked<ILandscapeEditorModule>("LandscapeEditor");
const ILandscapeHeightmapFileFormat* HeightmapFormat = LandscapeEditorModule.GetHeightmapFormatByExtension(*FPaths::GetExtension(Filename, true));
FLandscapeHeightmapImportData ImportData = HeightmapFormat->Import(*Filename, { (uint32)ExpectedWidth, (uint32)ExpectedHeight });
if (ImportData.ResultCode != ELandscapeImportResult::Error)
{
	Result = MoveTemp(ImportData.Data);
}
else
{
	UE_LOG(LogStreaming, Warning, TEXT("%s"), *ImportData.ErrorMessage.ToString());
	Result.Empty();
	bResult = false;
}
return bResult;

}