Add a Parcel Layer to the map
string path = @"C:\MyTestData\MyFileGeodatabase.gdb\MyFeatureDS\MyFabric";
await QueuedTask.Run(() =>
{
var lyrCreateParams = new ParcelLayerCreationParams(new Uri(path));
try
{
var parcelLayer = LayerFactory.Instance.CreateLayer<ParcelLayer>(
lyrCreateParams, MapView.Active.Map);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Add Parcel Fabric Layer");
}
});
Get the active record
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Active Record.");
Set the active record
string errorMessage = await QueuedTask.Run(async () =>
{
try
{
string sExistingRecord = "MyRecordName";
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
bool bSuccess = await myParcelFabricLayer.SetActiveRecordAsync(sExistingRecord);
if (!bSuccess)
return "No record called " + sExistingRecord + " was found.";
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Set Active Record.");
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.