I would like to add new coded values to an existing domain, but I don't know how to do that.
I tried to add values like that, but it doesn't work.
oDomainsList = oGeodatabase.GetDomains();
foreach (Domain oDomain in oDomainsList)
{
if (oDomain != null && oDomain is CodedValueDomain)
{
if(oDomain.GetName() == sDomainName)
{
(oDomain as CodedValueDomain).GetCodedValuePairs().Add("New value 1", "NV_1");
break;
}
}
}
I can create an new domain if it doesn't exists like this :
SortedList<object, string> oList = new SortedList<object, string> {{"Copper", "C_1"}, {"Steel", "S_2"}};
oCodedValueDomainDescription = new CodedValueDomainDescription(sName, FieldType.String, oList)
{
SplitPolicy = SplitPolicy.Duplicate,
MergePolicy = MergePolicy.DefaultValue
};
CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(oCodedValueDomainDescription);
schemaBuilder.Build();
But the domain is not overwritten if it exists.
I tried to delete the domain, hopping I could create a new with all coded values, but I don't know how to do that.
SchemaBuilder.Delete needs a Description parameter, but it looks like there is no way to get that from an existing domain.
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic40928.html
Remarks
When deleting domains, a CodedValueDomainDescription must be used to delete a ArcGIS.Core.Data.CodedValueDomain and a RangeDomainDescription must be used to delete a ArcGIS.Core.Data.RangeDomain.
There is no example.
Thanks