POST
|
I can't see anywhere to edit my post so I will reply to my own thread. A tip: You need to set the current template AFTER you start the editor. If you set the current template before starting the editor the editTemplate tool will not activate. //FAIL: the tool will not activate editor.CurrentTemplate = editTemplate; editor.StartEditing(dataset.Workspace); //PASS: the tool will activate editor.StartEditing(dataset.Workspace); editor.CurrentTemplate = editTemplate; I hope this helps others, I was setting the current template before starting the editor & the tool would not activate, I was pulling my hair out all due to the order of my code!
... View more
10-18-2010
12:20 PM
|
0
|
0
|
500
|
POST
|
Thanks Sean that helped a lot. I have finally got the editor going. Here's my code to help anyone else. IEditor3 editor = get_Editor(application) as IEditor3; IEditTemplateFactory editTemplateFactory = new EditTemplateFactoryClass(); IEditTemplate editTemplate = editTemplateFactory.Create("PolygonAreaTemplate", featureLayer); Guid polygonFeatureTool = new Guid("{8F79967B-66A0-4A1C-B884-F44BC7E26921}"); editTemplate.Tool = polygonFeatureTool; IArray templateArray = new ArrayClass(); templateArray.Add(editTemplate); editor.AddTemplates(templateArray); editor.StartEditing(dataset.Workspace); editor.CurrentTemplate = editTemplate;
... View more
10-13-2010
01:50 PM
|
0
|
0
|
500
|
POST
|
I have been able to create an editTemplate and start the editor but have not for the life of me been able to get the polygon contruction tool to start. On the editor toolbar I have to manually click the "Create Features" button which shows my editTemplate, I then have to manually click my editTemplate which then selects the Polygon construction tool. As to how you do this in code I'm unsure. I have tried IEditSketch & the StraightConstructor but still no joy. IEditSketch3 editSketch3 = editor as IEditSketch3; editSketch3.GeometryType = esriGeometryType.esriGeometryPolygon; IShapeConstructor shapeConstructor = new StraightConstructorClass(); shapeConstructor.Initialize(editor); editSketch3.ShapeConstructor = shapeConstructor; //This line throws an error "Item not found in collection" shapeConstructor.Activate();
... View more
10-12-2010
11:56 AM
|
0
|
0
|
500
|
POST
|
Hi John yep, I read all that but it still hasn't helped. I can't find any examples either. I'll just have to wait until others have the same problem which I'm guessing wont take long as the editor workflow is just so different now as to what it was in 9.3. Cheers Tony
... View more
09-16-2010
03:53 PM
|
0
|
0
|
500
|
POST
|
Hi I am trying to convert my ArcObjects 9.3.1 code to 10. I have a simple button that when clicked creates a new shapefile & adds it to the TOC. It then starts the editor & selects the Sketch Tool. The user then draws a polygon and the OnSketchEventHanlder then calculates the selected area the user just drew on the new shapefile. This is simple stuff but it wont work in ArcMap 10. Now I have to contend with what looks like templates & shapeconstructors. Ive managed to create a new template & add it to the template array, but I have no idea how to specifiy the editor to use the polygon construtor tool. The editor starts but the new shapefile is not selected & the polygon tools is not selected. How do I get it to use my template & use the polygon tool? Do i even need to do it this way with version 10? I see you can create a temporary feature within a template so I may not even need to create the new shapefile to use for editing??? Here's what I have so far internal static IEditor get_Editor(IApplication application) { IEditor editor = null; UID uidEditor = new UIDClass(); uidEditor.Value = "esriEditor.Editor"; editor = application.FindExtensionByCLSID(uidEditor) as IEditor; return editor; } internal static void StartEditing(IApplication application, string layerName) { IEditor3 editor = get_Editor(application) as IEditor3; //find the layer to edit IMxDocument mxDocument = (IMxDocument)application.Document; IFeatureLayer featureLayer = (IFeatureLayer)get_Layer(mxDocument, layerName); //check for existing templates & remove editor.RemoveAllTemplatesInLayer(featureLayer); //create a single template for the editable layer IEditTemplateFactory editTemplateFactory = new EditTemplateFactoryClass(); IEditTemplate editTemplate = editTemplateFactory.Create("PolygonAreaTemplate", featureLayer); //Add the template IArray templateArray = new ArrayClass(); templateArray.Add(editTemplate); editor.AddTemplates(templateArray); //Need some more code here use my template & use the polygon constructor tool IDataset dataset = (IDataset)featureLayer.FeatureClass; editor.StartEditing(dataset.Workspace); } Cheers Tony
... View more
09-13-2010
05:45 PM
|
0
|
9
|
859
|
POST
|
Hi sorpobear The "Register for COM interop" was ticked. I unticked it & the problem went away. Things are a done little different with Add-ins but I like it. Thanks Tony
... View more
08-24-2010
12:14 PM
|
0
|
0
|
1069
|
POST
|
Hi, I am using Windows 7 x64 with Visual Studio 2010 & ArcMap 10. When compiling an add-in for ArcMap 10 in Visual Studio I get the error: "Cannot register assembly "myaddin.dll" Could not load file or assembly "ESRI.ArcGIS.Desktop.AddIns". The system cannot find the file specified. I have made sure the reference to the file is there & it exists. The weird thing is when I compile it again, it comiles fine without error. Really annoying, every time I want to compile my project I have to compile it twice in order for it to succeed. Has anyone else seen this or know how to fix it? Thanks Tony
... View more
08-23-2010
03:28 PM
|
0
|
4
|
5790
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|