2 votos

¿No aparece el botón en el complemento de ArcMap?

Un compañero desarrollador de c# desarrolló un AddIn de ArcMap, pero ahora ha dejado el negocio.

He adquirido su portátil con el VS2010 y ArcMap 10.1. Puedo crear el archivo Esri Addin. Importarlo en la carpeta '~/Documents/ArcGIS/AddIns/Desktop10.1'.

Funciona bien en su máquina.

He instalado ArcMap10.1 y el .netFramework en mi PC importado el archivo Addin en la misma carpeta. Pero el botón de comando no aparece, por lo que no puedo seleccionarlo.

Aparece en mi lista de extensiones y está seleccionada. Aparece en mi Administrador de complementos pero sigue sin aparecer el botón cuando lo busco en la lista de comandos.

Por favor, ¿alguien puede indicarme la dirección correcta para resolver esto? Creo que hay algo que no está instalado pero no puedo averiguar qué puede ser.

El archivo Config.esriaddinx

  <ESRI.Configuration xmlns="http://schemas.esri.com/Desktop/AddIns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>****.ArcMapAddin.Bins</Name>
  <AddInID>{d64bdedc-d036-4aa3-9b1e-77129a2359bf}</AddInID>
  <Description>Collections Plugin</Description>
  <Version>1.0</Version>
  <Image>Images\****.ArcMapAddin.Bins.png</Image>
  <Author>**********</Author>
  <Company>*************</Company>
  <Date>25/02/2014</Date>
  <Targets>
    <Target name="Desktop" version="10.1" />
  </Targets>
  <AddIn language="CLR" library="****.ArcMapAddin.Bins.dll" namespace="****.ArcMapAddin.Bins">
    <ArcMap>
      <Extensions>
        <Extension id="*************.ArcMapAddin.Bins_ExtensionBins" class="ExtensionBins" productName="ArcMap.Bins" showInExtensionDialog="true" autoLoad="true" />
      </Extensions>
    </ArcMap>
  </AddIn>
</ESRI.Configuration>

El comando BaseCommandOpenBinsDialog.cs

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
using System.Collections.Generic;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System.Linq;
using System.Windows.Forms;

namespace ****.ArcMapAddin.Bins
{
    /// <summary>
    /// Summary description for BaseCommandOpenBinsDialog.
    /// </summary>
    [Guid("aea6924a-f7d7-4c83-84c7-898c63a04d82")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("****.ArcMapAddin.Bins.BaseCommandOpenBinsDialog")]
    public sealed class BaseCommandOpenBinsDialog : BaseCommand
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private class ArcMapWindow : System.Windows.Forms.IWin32Window
        {
            private IApplication m_app;

            public ArcMapWindow(IApplication application)
            {
                m_app = application;
            }

            public System.IntPtr Handle
            {
                get { return new IntPtr(m_app.hWnd); }
            }

        }

        private IApplication m_application;
        public BaseCommandOpenBinsDialog()
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "*************************"; //localizable text
            base.m_caption = "Bins";  //localizable text
            base.m_message = "Open Bins Dialog Box";  //localizable text 
            base.m_toolTip = "Configure Bins";  //localizable text 
            base.m_name = "****_Bins";   //unique id, non-localizable (e.g. "MyCategory_MyCommand")

            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (hook == null)
                return;

            m_application = hook as IApplication;

            //Disable if it is not ArcMap
            if (hook is IMxApplication)
                base.m_enabled = true;
            else
                base.m_enabled = false;

            // TODO:  Add other initialization code
        }

        private BinsForm binsForm;

        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            //get selected points
            IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;
            IList<int> selection = new List<int>();
            if (mxdoc.SelectedItem is IFeatureLayer2)
            {
                ILayer layer = mxdoc.SelectedLayer;
                IFeatureSelection featureSelection = layer as IFeatureSelection;
                var selectionSet = featureSelection.SelectionSet as ISelectionSet2;
                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }
            else if (mxdoc.SelectedItem is IFeatureLayer)
            {
                ILayer layer = mxdoc.SelectedLayer;
                IFeatureSelection featureSelection = layer as IFeatureSelection;
                var selectionSet = featureSelection.SelectionSet as ISelectionSet;
                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }
            else if (mxdoc.SelectedItem is ITable)
            {
                ITable table = mxdoc.SelectedItem as ITable;
                ITableSelection tableSelection = table as ITableSelection;
                var selectionSet = tableSelection.SelectionSet as ISelectionSet2;

                if (selectionSet != null)
                {
                    IEnumIDs enumIDs = selectionSet.IDs;
                    int id = enumIDs.Next();
                    while (id > 0)
                    {
                        selection.Add(id);
                        id = enumIDs.Next();
                    }
                }
            }

            if (selection.Count > 0)
            {
                this.binsForm = new BinsForm(selection.ToArray());
                this.binsForm.ShowDialog(new ArcMapWindow(ArcMap.Application));
            }
            else
            {
                MessageBox.Show("Before clicking this button select one or more points on the map and then select the feature layer.");
            }
        }

        #endregion
    }
}

1voto

StuartLC Puntos 133

Debe añadir la(s) barra(s) de herramientas y el(los) botón(es) al archivo de configuración, como se muestra a continuación.

  <AddIn language="CLR" library="xxxx.dll" namespace="xxxx">
    <ArcMap>
      <Commands>
        <Button id="My_Button" class="MyButton" message="TODO" caption="TODO" tip="TODO" category="TODO" image="Images\xxxx.png" onDemand="false" />
      </Commands>
      <Toolbars>
        <Toolbar id="My_Toolbar" caption="TODO" showInitially="true">
          <Items>
            <Button refID="My_Button"/>
          </Items>
        </Toolbar>
      </Toolbars>
      <Extensions>
        [your extension info]
      </Extensions>
    </ArcMap>
  </AddIn>

i-Ciencias.com

I-Ciencias es una comunidad de estudiantes y amantes de la ciencia en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X