I'm trying to adapt the EditingTemplates CreateTemplateWithCIM sample to write a template in which I have specified a default construction tool, and want to set some tool options on this custom construction tool. What I am seeing is that, despite trying a number of different ways to do so, the tool options are never persisted into the template using CIM. The tool options collection is always null when the construction tool is constructed. Setting the tool options using the Manage Template dialog works fine and everything works there. I tried this originally with Pro 2.9 and then adapted the sample to Pro 3.0 and still am not having luck.
Any tips on getting these tool options to save with the newly created template using CIM? Here is the relevant chunk of code that I've tried adapting.
//get the CIM layer definition
var layerDef = layer.GetDefinition() as CIMFeatureLayer;
//set new template values
var myTemplateDef = new CIMRowTemplate();
myTemplateDef.Name = "Daniel Template With Construction";
myTemplateDef.Description = "some description";
// set the default construction tool to our custom tool
myTemplateDef.SetDefaultToolID("EditingTemplates_Tools_ConstructFacilitiesTool");
myTemplateDef.AllowToolID("EditingTemplates_Tools_ConstructFacilitiesTool");
// Add default tool options for this construction tool
var toolOptions = new Dictionary<string, object>();
toolOptions.Add("CustomSubtype", "MySubtypeCode");
myTemplateDef.ToolOptions = new[]
{
new CIMEditingTemplateToolOptions()
{
//ToolProgID = "EditingTemplate_Tools_ConstructFacilitiesTool", I tried this to no avail
ToolProgID = "cdf8db34-6880-4e16-8253-145d739de379", // id from daml
Options = toolOptions,
}
};
var layerTemplates = layerDef.FeatureTemplates?.ToList();
if (layerTemplates == null)
layerTemplates = new List<CIMEditingTemplate>();
//add the new template to the layer template list
layerTemplates.Add(myTemplateDef);
//update the layerdefinition with the templates
layerDef.FeatureTemplates = layerTemplates.ToArray();
// check the AutoGenerateFeatureTemplates flag,
// set to false so our changes will stick
if (layerDef.AutoGenerateFeatureTemplates)
layerDef.AutoGenerateFeatureTemplates = false;
//and commit
layer.SetDefinition(layerDef);