Tag Info

Hot answers tagged

22

Keep in mind that Arcpy is essentially a wrapper around ArcObjects. But if you're just trying to call some Python scripts that you don't want to have to rewrite you can spawn a process that calls the python executable with your args. var startInfo = new ProcessStartInfo() { CreateNoWindow = false, UseShellExecute = false, FileName = ...


11

The answer to this question is yes and no. It is possible with some effort to do everything in Python that you could do in .Net, but easy and possible are two very different things. Following that, the simplest interpretation is no, Python Add-Ins cannot do as much as .Net Add-Ins. However, the tasks Python Add-Ins can accomplish are much easier and faster ...


8

Here is an unofficial and still untested solution from ESRI staff. (They did stress that this is not an official solution) Try removing from arcmap.exe.config, in the bin directory. This is the \ArcGIS\Desktop10.0\bin\arcmap.exe.config xml file.


8

I should have searched SO first, I would have found this answer. This seems to work: <Extensions> <Extension id="AmberGIS_ExtensionMgrAddin_ExtMgrExtension" class="ExtMgrExtension" productName="Extension State Manager" showInExtensionDialog="true" autoLoad="true"> <Description>Lets you specify extensions that will be ...


8

The add-in model is a new feature in version 10.0. This means you will not be able to use an add-in at lower versions, which require you to implement your commands, extensions, toolbars etc. in the older COM-only model.


7

As far as I can tell you are implementing the error handling that ESRI is currently putting out there as best practice. If you were to grab a hold of the application's (ArcMap) unhandled exceptions you could potentially be then displaying messages about errors that were not part of your AddIn. Most of the AddIns you write are probably going to be buttons ...


5

Try using the SetWindowPos winapi call with the hWnd of the dockable window control (or maybe it's parent or grandparent container control) with the HWND_TOP flag.


5

Right so I figured out how to configure the addin. Thanks to the suggestions from other people - I've commented where relevant - I'm not simply adding my own answer for point-whoring purposes, but none contained the full approach. The addin file in ...Documents\ArcGIS\AddIns\Desktop10.0... gets expanded every time ArcMap loads, so the only place that ANY ...


5

The Python option works for me: c:\Python26\ArcGIS10.0\python.exe C:\sandbox\py\misc\UpdateAddInVersionNumber.py "$(ProjectDir)Config.esriaddinx" (Python gurus, feel free to jump in and make it better) UpdateAddInVersionNumber.py: import os, sys import xml.dom.minidom import datetime filename = sys.argv[1] print filename b = 0 doc = ...


5

I'm not sure how accurate this is, but I've done this in the past: Create a LayerExtension class that implements ILayerExtensionDraw. Within the class keep a list of timings. A Timing is a class with a start tick and an end tick property. When BeforeLayerDraw is called for esriDPGeography, instantiate a new timing intance and set the StartTick property ...


5

Yes, since you are presumably using VB.NET (not VB, which is 20+ years old and no longer supported), you need to use the Imports statement to import namespaces. Specifically you want to put Imports ESRI.ArcGIS.Geometry at the top of your code files. Alternatively you could fully qualify the IPoint type every time you use it (ESRI.ArcGIS.Geometry.IPoint) ...


5

I have been struggling with this for a long while too. For example the standard blue dot icon for a button does show, but all my custom icons did not. By default Visual Studio sets the build action for an image you add to the solution to 'Content'. Apparently this has to be set to 'AddInContent'. After I changed this, all my button images where visible.


5

Yes there are several ways to do this. I would recommend building a script tool and packaging it with your add-in. I have a sample project that does this listed in this answer: How can I programmatically get the path of "Python.exe" used by ArcMap See also: Running Arcpy script from ArcObjects Leveraging ArcPy in a .NET application


4

Doh! Yes it is possible to reference a built-in command (button) on a custom menu/toolbar (What I really need to do). It is not possible to redefine a built-in command (What I was trying to do). One can reference a built-in command on a custom menu/toolbar like this. <Menu id="my_id" caption="Cool_tools"> <Items> ...


4

Borrowing from a similar answer, you might use this in your addin: string configPath = System.IO.Path.Combine(this.GetType().Assembly.Location,"Config.xml");


4

The only time I have gotten this is when I had another ArcMap instance open and forgot to close it before building/debugging. If you don't close all instances using the assembly then the old one will continue to be used. Or something like that.


4

In your code that you gave as an example. In my testing this worked for me. new Thread(() => { MessageBox.Show(String.Format("The value '{0}' is not an integer!", currentValue)); }).Start(); Edit To incorporate the great comments, and as Petr pointed out that this way may be dangerous here is the other way of doing this as well: ...


4

This may be a better way then trying to read the registry key. This page can be used as a lookup from version number to service pack. Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion


4

@ChadCooper, perhaps I'm overlooking something, but with regard to your 3rd case: A Python script that launches a PyQT/wxPython/Tk GUI.. Is there a reason why you couldn't use the .Net Process API (see System.Diagnostics) to execute your custom Python script over Standard In/Out? Of course, this sort of architecture will assume a proper version of ...


4

The key to proper parenting of WPF windows within a non-WPF application is to use the WindowInteropHelper class. Suppose you have a WpfWindow class which is a WPF window (derives from Window): private void ShowWpfWindowModal() { var parentHandle = new IntPtr(_app.hWnd); // the ArcMap window handle var wpfWindow = new WpfWindow(); ...


4

According to the official documentation: ArcGIS for Desktop, ArcGIS Engine, or ArcGIS for Server is required to develop with ArcObjects SDK. Microsoft .NET Framework 3.5 Service Pack 1


4

.Net 4 is supported by ArcGIS 10.1, but there is a little extra work you will need to do. http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//000100000nzv000000 If you require any of the .NET 4.0 Framework functionality, you can extend Esri products with components written in the .NET 4.0 Framework. However, it's your ...


4

Not sure if this is the current source code, but it does look like a lot of buttons are tied to an edit session and if the extension enabled. Also go to Menu Customization-->Extensions and see if there is an entry for your extension that is unchecked.


3

As my project's .NET Framework is 4.0, I changed to supportedRuntime version="v4.0.30319" in ArcMap.exe.config and I noticed that the problem was delayed by this change. I also remembered that ArcMap also loads ArcCatalog so I changed also ArcCatalog.exe.config to supportedRuntime version="v4.0.30319" and YES!!! It's working again. I spent all day trying to ...


3

I believe you have to refresh via IMapSurround. See code below. Dim pMxDoc As IMxDocument Dim pPageLayout As IPageLayout Dim pGC As IGraphicsContainer Dim pElem As IElement Dim pMSF As IMapSurroundFrame Dim pMS As IMapSurround Set pMxDoc = ThisDocument Set ...


3

Don't bother about the "OGR layer converter", it was obsolete so it was removed from QGIS (starting from 1.7). The "Add Postgis Layer" tool will allow you to export/import Postgis connections.


3

2 years and 2 version later and this is still a problem. Just finished updating/improving all my addins for 10.2 and came across this problem again. Implemented ALL sugestions in this post and nothing worked but I have discovered 1 additional possible problem. Unfortunately, I am not sure if this was the culprit or not because I've also implemented most ...


3

You can use dictionaries for this type of thing. There are more memory efficient ways of doing this (by just storing field names once), but this might get you started. public void TestGetSelection() { var dict = GetSelection(ArcMap.Document.FocusMap.get_Layer(0) as IFeatureLayer); foreach (KeyValuePair<int, Dictionary<string, object>> ...


3

Yes. Use the ExtensionManager class.


3

Unfortunately it appears that the ILayerExtensionDraw.BeforeLayerDraw and AfterLayerDraw events are only fired by feature and network layers (see wguidry's post here) and I need to support raster layers, map/image services, mosaic datsets, etc. So in a nutshell here is what I ended up doing. Thanks @Kirk again for the ideas! Created the following classes: ...



Only top voted, non community-wiki answers of a minimum length are eligible