Saturday, September 19, 2015

Getting started with ArcObjects 1


Getting started with ArcObjects 1

In this post we will see how to use the ArcGis templates in .Net, how to create the default toolbar and add some default command buttons in the toolbar.

Expected prerequisites for this session is 1.DotNet 2010 and 2.ArcGIS 10.2 should be installed your desktop. Installations part we will cover in coming posts.

Run DotNet 2010 with administrator privileges
Create new project by clicking on File -> New -> Project

 From installed templates list select ArcGIS -> Extending ArcObjects then choose Class Library (ArcMap) and .Net Framework 4. If you want you can change the Project Name, Location and Solution name by changing the below textbox text.
.
Once you done with all click on OK button. Right now i am creating with default name ArcMapClassLibrary1. As soon as you click on OK, you will prompt with other wizard as shown in below
For now i suggest to select all the Assemblies under Desktop ArcMap by holding Ctrl and select. Then click Add, you can see all the selected items listed below. Then click Finish.
You can see one empty class with some default code as shown in below.


Select the project and right click and choose add -> NewItem as shown below
As soon as you choose you select you can prompt with Add New Item wizard.
Goto ArcGIS -> Extending ArcObjects select Base Toolbar. If you want you can change the name. I changes it as "BloggerTestToolbar.cs".

Click Add. You will prompt with another wizard


choose Desktop ArcMap and click OK. You can see one template added to your project with some Namespaces, COM Registration Functions, Guid, ProgId, some methods and some commented code as shown in below.

Change the caption, and uncomment the constructor code as shown in below. I changed the caption to "My Blogger First C# Toolbar".

Once its done, its done. You created your first ArcMap tool bar with Zoom, Undo and Redo commands. Don't believe.... build your application and open the ArcMap, Go to Customize -> Customize Mode..

Toolbars -> search for your toolbar and select
New toolbar created with Zoom, Undo and Redo commands. Its as simple as we don't believe.You can add layers and you can play with these buttons.

In next post we will see how its possible and some important points on this toolbar class.






Saturday, September 5, 2015

How to read ArcObjects - Object Model Diagrams - 3

Reading Object Model Diagrams

In last post we learned about UML - Class types. If anyone missed please refer the below link :

In this post we will discuss about UML Properties and Methods.

UML Property symbols:

Read and write property - 
All classes have properties on then shown with the barbell symbol as shown above. Chicken class has 3 properties like Age, Color and Name.

Read only property -
Some of the properties have a left-sided barbell, means we can only get this value, we cannot change it to something else (read only). Here, for chicken we could get reference to its wing, but we could not give it a different wing.

Write only property - 
Some of the properties have a right-side barbell. we can edit the value, but we can never find out what it is. Here, for chicken we could change the password, but we never know what the current password setting is.

Property Values -
To the right of each property are a colon and then a type. This is the value type that the property holds. Age holds an integer value like 1,2,3... Some properties holds objects or reference of objects. So, here, the wing property would give us a reference to a wing object.

UML Method symbols:
Classes also have methods. Methods are shown with an arrow symbol. Methods are like the actions that an object can perform.

Some methods returns the values, some don't. Fly does not return any value. It carries out its operation and that't it. LayEgg, on the other hand, carries out it's operation and returns an Egg object for us. This is how chicken creates egg with LayEgg method.