Tag Archives: Add-in

New Query Tool for ArcGIS Viewer for Silverlight

The ArcGIS Viewer for Silverlight development team is excited to share a new query tool for the Viewer on ArcGIS Online.  This tool allows users of the Application Builder to interactively build queries against ArcGIS Server services, presenting end-users with a simple dialog box that prompts for values to plug into the query.
Continue reading

Posted in Web | Tagged , , , , , , | 5 Comments

The ArcGIS Query Analysis Add-In is available for download

Investigate query results with the SPOT tool

The Query Analysis Add-In is available for download.  At 10.1, the Query Analysis Add-In expands support for rasters to include building complex queries over multiple single-band rasters. The Query Analysis Add-In is designed to rapidly create a query that consists … Continue reading

Posted in Defense, Imagery | Tagged , , , , , , , , , , , , , , | 2 Comments

The ArcGIS Full Motion Video Add-In is available for download

ArcGIS Full Motion Video Add-In 1.0

The ArcGIS Full Motion Video 1.0 Add-In (for ArcGIS 10 and for ArcGIS 10.1) is available for download from Arcgis.com. This Add-In allows you to play live streams of video or video files in your map.  Frames from the video … Continue reading

Posted in Defense | Tagged , , , , , , , , | 13 Comments

Incorporating snapping into custom tools

If you are writing a custom tool in ArcMap to select features or create geometry a certain way, then you’ll often need to make it snap to existing features on the map. In the past, snapping was restricted to editing and was somewhat cumbersome for developers to implement. However, ArcGIS 10 provides the ArcGIS Snapping Environment, which offers users a simplified experience in ArcGIS Desktop or ArcGIS Engine and gives developers a straightforward application programming interface (API) to enable snapping in custom tools. This blog entry introduces you to the snapping API and provides sample code that demonstrates how you can incorporate snapping into your own tools.

To implement snapping in a tool, there are two options available depending upon if the tool will be used while editing. If your tool will be used both inside and outside an edit session, you can implement snapping directly by going through the snapping extension. If your tool will be used exclusively within an edit session, you can access snapping indirectly through the Editor object, which takes care of most of the initialization work for you.

Implementing snapping via the extension
First, I am going to show you how to access the snapping environment directly using its extension. This is applicable for a tool that can be used both inside and outside of an edit session. To demonstrate this, I develop a simple tool that reports the x,y location of a mouse click at its snapped location.

I start by creating a tool add-in by following the directions from the SDK help topic, Building add-ins for ArcGIS Desktop. Then, with the help of Working with the ArcGIS snapping environment, I add the code required to enable snapping in the tool. After adding a reference to the ESRI Controls assembly, I can access and initialize the snapping environment in my tool’s Click event. For add-in tools, this event is the OnActivate method.

Next, I can use the cursor location returned from the tools MouseMove event and determine if it actually snaps to anything. If it does, then I update a variable with the snapped position.

The complete code sample is shown below.

using ESRI.ArcGIS.Controls;

using
ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;

namespace
ToolWithSnapping

{


public
class
ShowMapCoordinates
: ESRI.ArcGIS.Desktop.AddIns.Tool


{



ISnappingEnvironment m_SnappingEnv;



IPointSnapper m_Snapper;



ISnappingFeedback m_SnappingFeedback;



IPoint m_Position;


public ShowMapCoordinates()


{


}


Protected override
void OnActivate()


{



//Get the snap environment and initialize the feedback



UID snapUID = new
UID();



snapUID.Value =
“{E07B4C52-C894-4558-B8D4-D4050018D1DA}”
;



m_SnappingEnv = ArcMap.Application.



FindExtensionByCLSID(snapUID) as
ISnappingEnvironment;


m_Snapper =
m_SnappingEnv.PointSnapper;



m_SnappingFeedback = new
SnappingFeedbackClass();



m_SnappingFeedback.Initialize(ArcMap.Application,
m_SnappingEnv, true);


}


protected override
void OnMouseMove(MouseEventArgs
arg)


{



//Get the current position in map units



//This is the cursor location before snapping


m_Position
= ArcMap.Document.ActiveView.



ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);


ISnappingResult snapResult =
null;


//Try to snap the current position


snapResult
= m_Snapper.Snap(m_Position);


m_SnappingFeedback.Update(snapResult, 0);



if (snapResult != null)



//Snapping occurred



//Set the current position to the snapped location



m_Position = snapResult.Location;


}


protected override
void OnMouseDown(MouseEventArgs
arg)


{



System.Windows.Forms.MessageBox.Show(“Map units:rnX: “



+ m_Position.X.ToString() + “rnY: “ +
m_Position.Y.ToString());


}


protected override
void OnRefresh(int
hDC)


{



if (m_SnappingFeedback !=
null)



m_SnappingFeedback.Refresh(hDC);


}


}

}

In my code, the variable m_Position holds the snapped position of the cursor. If my tool were creating geometry or updating screen feedback (such as with INewLineFeedback), then I would use the m_Position variable rather than the mouse position (MouseEventArgs) as the update point.

Implementing snapping in an edit session
As I mentioned before, if you are developing a tool that will be used exclusively in an edit session, implement snapping with the help of the Editor object. The main advantage of doing this is that the Editor will work with either the ArcGIS Snapping Environment or editing classic snapping, but only in an edit session, of course. Classic snapping refers to the snapping functionality that was available during an edit session in ArcGIS 9 and allows you to set up snapping in a more complex manner on a layer-by-layer basis. The ArcGIS Engine edit sketch and any custom tools that derive it are limited to the classic snapping environment.

Generally speaking, there two types of Editor tools you can build: those that use the edit sketch and those that don’t. You would typically use the edit sketch in a tool if you wanted to use the sketch to help you create some geometry or feedback on the screen. You can then take that geometry and use it as the basis to create a feature with it or use it for selections. If you are creating an ArcMap tool that uses the edit sketch, you don’t have to worry about snapping at all since the Editor handles it entirely for you. The edit sketch also comes with its own context menu (the one used by the Polygon or Line construction tools) and shape constructors, so it’s convenient for developers. In ArcGIS 10, you can only build a tool that uses the edit sketch through COM, which creates a .dll.

If you are not using the edit sketch in your tool, which is most likely because it doesn’t provide the geometry you need, then there is a bit more work involved because you have to create your own geometry using mouse clicks and implement snapping yourself. This type of tool can be made into an add-in or COM .dll.

For the sample code, I’ll use the same example of an add-in tool that reports the x,y position of the snapped location. In this case, I only have to reference the Editor and not the Controls assembly to enable snapping.

using
System;

using
ESRI.ArcGIS.Editor;

using
ESRI.ArcGIS.Geometry;

namespace
ToolWithSnappingES

{


public
class
ShowMapCoordinatesES
: ESRI.ArcGIS.Desktop.AddIns.Tool


{



IEditor m_Editor =
null
;



IPoint m_Position =
null
;


public ShowMapCoordinatesES()


{


m_Editor =
ArcMap.Application.FindExtensionByName(“esriEditor.Editor”)
as
IEditor;


}



protected override
bool OnDeactivate()


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, 0);


m_Position
= null;



return true;


}



protected override
void OnMouseMove(MouseEventArgs
arg)


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, 0);


m_Position
= m_Editor.Display.DisplayTransformation.ToMapPoint(arg.X, arg.Y);



//Get the snap environment from the editor



ISnapEnvironment se = m_Editor
as ISnapEnvironment;



Boolean snapped = se.SnapPoint(m_Position);



m_Editor.InvertAgent(m_Position, 0);


}



protected override
void OnMouseDown(MouseEventArgs
arg)


{



System.Windows.Forms.MessageBox.Show(“Map units:rnX: “



+ m_Position.X.ToString() + “rnY: “ +
m_Position.Y.ToString());


}



protected override
void OnRefresh(int
hDC)


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, hDC);


}



protected override
void OnUpdate()


{


Enabled =
(m_Editor.EditState == esriEditState.esriStateEditing);


}


}

}

The code is very similar to the extension example, where the variable m_Position holds the snapped position and would be used to create geometry or update feedback. In this case, I have to be careful with refreshing the feedback. The code calls InvertAgent, which essentially paints the screen with the feedback of a blue dot. To erase the feedback, I need to call InvertAgent again. If I get out of sync, I can be left with feedback graphics on the screen that will not go away until I refresh the screen. Normally, though, if you are working with ArcGIS Snapping, the environment takes care of this for you.

For more information
To learn more about developing with the ArcGIS Snapping environment, see Snapping in ArcGIS in the ArcGIS Developer Help.

To view some example editing tools that incorporate snapping, see the Editing Labs group on ArcGIS.com (make sure to filter by Show: All Content at the top of the page).

Post content from Sean (Editing Team)

Posted in Developer, Editing | Tagged , , , , , , , , , , | Comments Off

Moving to Add-ins (Recycling VBA)

In the Spring edition of ArcUser there is a nice article by Craig Gallant (LJB Inc) on converting existing projects to ArcGIS Add-ins.

Here how’s the article starts…

You might ask this after installing ArcGIS 10. With the release of ArcMap 10, Visual Basic for Applications (VBA) is on the way out. As the online help article “Migrating VBA customizations to ArcGIS 10″ explains, “VBA no longer provides the best toolset for customizing ArcGIS and is not included in the default installation.”

At ArcGIS 10, there are two new ways to customize in ArcGIS 10: Python and the new ArcGIS Desktop Add-in. [Add-ins are a new way to customize and extend ArcGIS 10. They are authored in .NET or Java and Extensible Markup Language (XML). They provide a declaratively based framework for creating a collection of customizations that can be conveniently packaged in a single compressed file that is easily shared. Add-ins do not require installation programs or Component Object Model (COM) registration.] Both options have advantages and disadvantages. You need to pick the option that best suits your application. This article shows how, with a little refactoring, existing VBA code can quickly be converted to an ArcGIS Desktop Add-in.

for more see ArcUser Online

 

Posted in Developer | Tagged , , , , , , , , , , , | Leave a comment

Customizing the editing environment: Changing feature template properties

Feature templates provide an easy way to streamline the creation of features while editing. Choosing a feature template determines which layer the feature will be created in, the attributes the new feature will have, and the default construction tool that will be used to create the new feature. These properties can be changed through the user interface or developer customizations.

This post explains how an add-in can update a feature template property. I posted it to the Editing Labs group on ArcGIS.com so other users can install it. The add-in can be accessed directly at http://esriurl.com/2066.

Setting the default feature construction tool
I am editing a layer of building features and need to create new footprint polygons.  My map contains feature templates with default attributes for each category of building I am capturing, such as Office, Residential, and Retail types. The Polygon tool is currently set as the default construction tool for all the templates. Because I am going to draw mostly rectangular features, I can set the default construction tool to Rectangle so that tool automatically becomes active on the Create Features window instead. Setting an appropriate default tool helps me avoid the extra click to switch from the Polygon tool to the Rectangle tool when drawing the rectangular buildings.

While I could change any feature template property manually on the Organize Feature Templates dialog box or the Template Properties dialog box, a simple add-in customization is an easy way to do it quickly for multiple feature templates at once. This add-in updates the default construction tool for all feature templates in a layer.

 

Writing the add-in
I can create the add-in within Visual Studio as an ArcMap button add-in. I’ll need to reference ESRI.ArcGIS.Carto and ESRI.ArcGIS.Editor, in addition to the default ESRI add-in references.
The full code for the add-in is as follows:

 
public class
SetTemplateTool : ESRI.ArcGIS.Desktop.AddIns.Button

  {

   
IEditor3 m_editor;

 

   
public SetTemplateTool()

    {

     
m_editor = ArcMap.Application.FindExtensionByName(“esriEditor.Editor”)
as
IEditor3;

    }

 

   
protected override
void OnClick()

    {

     
// get the selected template and current tool

     
IEditTemplate currentTemplate =
m_editor.CurrentTemplate;

     
ICommandItem currentTool =
ArcMap.Application.CurrentTool;

 

     
for (int
i = 0; i < m_editor.TemplateCount -1; i++)

     
{

       
IEditTemplate editTemplate =
m_editor.get_Template(i);

       
if (editTemplate.Layer.Name ==
currentTemplate.Layer.Name)

       
{

         
Guid g = new
Guid(currentTool.ID.Value.ToString());

         
editTemplate.Tool = g;

       
}

     
}

    }

   
protected override
void OnUpdate()

    {

     
this.Enabled = (m_editor.EditState ==
esriEditState.esriStateEditing);

    }

  }

The code simply loops through all the possible templates in the map during an edit session, identifies those that share the same layer as the currently selected template, and sets the default tool on those templates to the tool active in the Construction Tools portion of the Create Features window. It is important to note that this code only works within an edit session. I can still make programmatic changes to feature templates in a map outside of an edit session, but I must set them via the layer extension instead of the Editor object that already knows about all templates in the map.  

While this particular add-in only changes the default tool for a template, I could have also changed the default values for other template properties during this edit session via the properties and methods on IEditTemplate. For more information on working with feature templates, see Using feature templates in the ArcGIS 10 ArcObjects .NET SDK help.

Content provided by Sean Jones (Editing Team)

Posted in Developer, Editing | Tagged , , , , , , , , , , | Comments Off

VBA licensing at ArcGIS 10

ArcGIS 10 is the last release to support development with Visual Basic for Applications (VBA). Traditionally, VBA has been a convenient way to add functionality within your ArcGIS Desktop application, but as the software moves forward, we have newer and simpler methods for customization.

With the release of ArcGIS 10, we’ve introduced and expanded several of the methods for customizing, extending, and scripting in ArcGIS Desktop. As we’ve introduced new methods, we are deprecating support for VBA in ArcGIS Desktop. Moving forward, we encourage you to make use of some of the more robust solutions for extending ArcGIS Desktop. These solutions include the new desktop add-in framework, python scripting, and the standard com extensibility model (writing custom components). At ArcGIS 10, you may still use VBA while in the process of migrating your code, but there will be no VBA support as of ArcGIS 10.1.

To continue using VBA at ArcGIS 10, you must request a VBA authorization number from your customer service representative. The VBA authorization numbers are not included with the VBA install, nor included automatically with other authorization numbers you may have received. If you wish to obtain the VBA authorization number, please send an email directly to your customer service representative.

Update for ArcGIS 10.1
We realize that some of you still have VBA code in your workflows and we want you to be able to take advantage of ArcGIS 10.1 for Desktop.  To keep running your existing VBA code at 10.1 you’ll need to download and install the ArcGIS VBA Compatibility setup and then request a VBA authorization similar to ArcGIS 10.
Note – There is no ArcObjects SDK for VBA at 10.1 as new development with VBA is not supported.

Posted in Developer | Tagged , , , , , , , | Leave a comment

Developing Add-Ins for ArcGIS Desktop 10

The next live training seminar on ArcGIS 10 is this Thursday. This Seminar will introduce you to the new way to customize and extend
ArcGIS Desktop using the Microsoft .NET Framework. ArcGIS Desktop 10
introduces the new Add-In framework to easily build and share solutions.

This seminar is for ArcGIS Desktop users who want to learn how to create or share ArcGIS Desktop add-ins

Thursday, September 30, 2010
9:00 a.m., 11:00 a.m., & 3:00 p.m. Pacific Time (US & Canada)
12:00 p.m., 2:00 p.m., & 6:00 p.m. Eastern Time (US & Canada)
4:00 p.m., 6:00 p.m., & 10:00 p.m. UTC/GMT 

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

Tips and Tricks for Using ArcObjects in Microsoft Visual Studio

This video
tutorial
illustrates how to use some of the new Microsoft Visual Studio 2008
and 2010 integration features available with ArcGIS 10 such as project
templates, snippets, references, help documentation, and samples.

Special thanks to Katy from the SDK team for putting this together.

 

 

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment