Select to view content in your preferred language

Set Default Construction Tool

287
1
Jump to solution
09-23-2024 01:50 PM
JonathanDewalt
Regular Contributor

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);

}

0 Kudos
1 Solution

Accepted Solutions
JonathanDewalt
Regular Contributor

Figured it out.

Can not use:

cimEditTemplate.GetDefaultToolID =  "rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine";

must use:

cimEditTemplate.SetDefaultToolID("rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine");;

 

View solution in original post

0 Kudos
1 Reply
JonathanDewalt
Regular Contributor

Figured it out.

Can not use:

cimEditTemplate.GetDefaultToolID =  "rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine";

must use:

cimEditTemplate.SetDefaultToolID("rmg_AlbertaWildfireTools_Buttons_Editing_ConstructionTool_FireLine");;

 

0 Kudos