Hello,
I have code that removes all standard construction tools and adds my custom construction tool but for some reason the setDefualtToolID function does not work or at least the tool is not selected by default. My tool is the only one available so that works and the tool works when I use it, it is just not automatically selected.
CIMFeatureLayer? layerDef = null;
var newCIMEditingTemplates = new List<CIMEditingTemplate>();
var editTemplates = layer.GetTemplates();
foreach (var et in editTemplates)
{
//initialize template by activating default tool
et.ActivateDefaultToolAsync();
var cimEditTemplate = et.GetDefinition();
//get the visible tools on this template
var allTools = et.ToolIDs.ToList();
//add the hidden tools on this template
allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList());
cimEditTemplate.SetExcludedToolIDs(allTools.ToArray());
cimEditTemplate.AllowToolID("rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FirePoint");
cimEditTemplate.DefaultToolGUID = "rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FirePoint";
newCIMEditingTemplates.Add(cimEditTemplate);
}
//update the layer templates
layerDef = layer.GetDefinition() as CIMFeatureLayer;
if (layerDef != null)
{
layerDef.AutoGenerateFeatureTemplates = false;
layerDef.FeatureTemplates = newCIMEditingTemplates.ToArray();
layer.SetDefinition(layerDef);
}
Solved! Go to Solution.
Figured it out.
Can not use:
cimEditTemplate.GetDefaultToolID = "rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine";
must use:
cimEditTemplate.SetDefaultToolID("rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine");;
Figured it out.
Can not use:
cimEditTemplate.GetDefaultToolID = "rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine";
must use:
cimEditTemplate.SetDefaultToolID("rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine");;