[GIS] How to programmatically add a new feature template to the “Create Feature dockable window”

arcgis-10.0developmentnet

This is a new question but a continuation of this post: How can I programmatically display the "Create Features" dockable window in ArcMap 10?

I like the new template system in ArcGIS 10 but for quick editing it is a somewhat cumbersome several-click process. I have a tool that starts editing a layer that is currently selected in the TOC. It also pops the "Create Feature" dockable window.

I would like to add the currently selected layer as a template to the dockable window using it's default symbology. (VB.Net)

Best Answer

This involves a two-step approach.

  1. You create the edit template for your layer via IEditTemplateFactory.Create method.
  2. Add the template to the Editor by calling IEditor3.AddTemplates.

EDIT: If you do not want to duplicate the templates on every edit session start, I suggest you read the conceptual documentation for layer templates. It provides a good overview and also shows how to persist the layer templates by accessing the layer's template extension IEditTemplateManager, which may be useful in your case. The document also implies that any advanced template creation (e.g. based on the more advanced renderers) has to be done on your own, this functionality used ArcMap is not exposed as an API to be reused by developers.