POST
|
The code sample below shows how one can add a map service to ArcMap using the GxCatalog dialog. using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.CatalogUI;
using ESRI.ArcGIS.Catalog;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using System.Windows.Forms;
using ESRI.ArcGIS.GISClient;
using ESRI.ArcGIS.esriSystem;
namespace GxDialog_Select_MapService_Layer
{
public class GxDialog_Select_MapService_Layer : ESRI.ArcGIS.Desktop.AddIns.Button
{
public GxDialog_Select_MapService_Layer()
{
}
protected override void OnClick()
{
IMxDocument pmxdoc = (IMxDocument)ArcMap.Application.Document;
IMap pmap = pmxdoc.FocusMap;
IGxDialog pGxDialog = new GxDialog();
pGxDialog.Title = "Browse Data";
//pGxDialog.set_StartingLocation("C:\\Temp");
pGxDialog.set_StartingLocation("GIS Servers");
IEnumGxObject pEnumGx;
if (!pGxDialog.DoModalOpen(0, out pEnumGx))
return; // Exit if user presses Cancel
IGxObject pgxobject = pEnumGx.Next();
IGxAGSObject gxAGSObject = pgxobject as IGxAGSObject;
IAGSServerObjectName agsServerObjectName = gxAGSObject.AGSServerObjectName;
IAGSServerConnectionName agsServerConnectionName =
agsServerObjectName.AGSServerConnectionName;
IPropertySet propertySet = agsServerConnectionName.ConnectionProperties;
//create a new ArcGIS Server connection factory
IAGSServerConnectionFactory2 agsServerConnectionFactory2 =
(IAGSServerConnectionFactory2)new AGSServerConnectionFactory();
IAGSServerConnection agsServerConnection =
agsServerConnectionFactory2.Open(propertySet, 0);
//get an enum of all server object names (services) from the server
IAGSEnumServerObjectName soNames = agsServerConnection.ServerObjectNames;
IAGSServerObjectName3 soName = (IAGSServerObjectName3)soNames.Next();
ILayerFactory msLayerFactory = new MapServerLayerFactory();
IEnumLayer enumLyrs = msLayerFactory.Create(soName);
IMapServerLayer mapServerLayer = (IMapServerLayer)enumLyrs.Next();
pmap.AddLayer(( ILayer)mapServerLayer);
ArcMap.Application.CurrentTool = null;
}
}
}
... View more
12-14-2015
05:26 PM
|
0
|
0
|
205
|
POST
|
I re-wrote the above code into an Add-in button that fetches the first featureclass in ArcMap's Table of Contents, and then creates a feature cursor, and then deletes all the features in the cursor (which ultimately deletes the features from the featureclass), but was unable to reproduce your error. protected override void OnClick()
{
IMap map = ArcMap.Document.FocusMap;
IFeatureLayer featureLayer = map.get_Layer(0) as IFeatureLayer;
IFeatureClass featureClass = featureLayer.FeatureClass;
IFeatureCursor featureCursor = featureClass.Search(null, false);
IFeature feature;
while ((feature = featureCursor.NextFeature()) != null)
{
feature.Delete();
}
} It is possible that you are receiving the error due to a lock issue. Make sure that no other instance of ArcMap or ArcCatalog has a lock on that feature class when you execute your code.
... View more
12-01-2015
07:04 PM
|
0
|
0
|
248
|
POST
|
When adding a feature to your feature class (programmatically), ensure that the geometry type is ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon. Creating Features http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/00010000049v000000.htm You can perform a validation of your newly created feature(s) before actually using the featureclass to create an insert cursor: Validating Features http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Validating_features/000100000mr7000000/
... View more
11-30-2015
06:33 PM
|
0
|
0
|
1535
|
POST
|
This exception will occur if the object returned by the following method is in fact not an IFeatureClass residing in a geodatabase: IFeatureClass sourceFeatureClass = source.DataSource.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(source.SourceTableName); I am thinking that your source.SourceTableName above is in fact just a normal excel CSV file (table) or a shapefile, and not really a table/feature class coming from a real geodatabase. Remember, Subtypes can only be created on a feature class (or table) residing in a geodatabase. This means, it has got to be a feature class (or table) residing in (a) a Personal Geodatabase, (b) File Geodatabase, (c) ArcSDE Geodatabase (multiuser geodatabase). A shapefile would not work. An Excel CSV table would not work. The below line of code would fail (you cannot cast a shapefile or CSV excel table to an ISubtypes Object) because subtypes are only available within the geodatabase container. ISubtypes subtypes = (ISubtypes)sourceFeatureClass; Try replacing source feature class with a known feature class residing in a file geodatabase or an ArcSDE geodatabase, and see if you still get the error. Documentation on Subtypes can be found at the below URLs: A Quick tour of Subtypes http://resources.arcgis.com/en/help/main/10.2/index.html#/A_quick_tour_of_subtypes/005r00000001000000/ Creating Subtypes (using ArcCatalog) http://resources.arcgis.com/en/help/main/10.2/index.html#/Creating_subtypes/005r00000003000000/ Creating Subtypes (using ArcObjects) http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/0001000003r3000000.htm
... View more
11-02-2015
06:25 PM
|
1
|
0
|
1803
|
POST
|
There could be several reasons for the error you are getting. One of the causes of this error has to do with the schema of the feature class that's passed in. By this, I mean the field names. Try and pass in a null string for the subFields parameter in your PerformSpatialQuery() method, and see if this resolves the error. See this Web page in the ArcObjects Online Help: IQueryFilter.SubFields Property http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000006n4000000
... View more
11-02-2015
12:58 PM
|
1
|
1
|
664
|
POST
|
The issue is probably caused by one or more of the parameters in your tinEdit.AddFromPixelBlock() not being compatible input into the method. I noticed that the last two parameters are supposed to passed in "by reference", but it appears that the last parameter has been passed in as "out toleranceAchieved". This could be causing your problem. Try replacing the last two parameters with "null" objects in accordance with the example provided on the Help page below: ITinEdit.AddFromPixelBlock Method http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000008wz000000 It says somewhere on the page: Optional Values pMaxPoints To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing. pbToleranceAchieved To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing. Replace the last two parameters with "ref Missing" and see if this resolves your issue.
... View more
10-29-2015
06:25 PM
|
1
|
0
|
278
|
POST
|
It appears that you are using pure Microsoft .NET libraries to open your OleDB connection. Try to use the ESRI libraries and see if you still get the error. Documentation on how to use OleDB connections with ArcObjects is below: DataSourcesOleDB http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001p0000000t000000 FdoAdoConnection CoClass http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/FdoAdoConnectionClass_Class/001p00000005000000/ Object Model Diagram - DataSourcesOleDB http://resources.arcgis.com/en/help/arcobjects-net/pdf/DataSourcesOleDBObjectModel.pdf
... View more
10-23-2015
12:27 PM
|
1
|
0
|
484
|
POST
|
One option would be to use an existing System geoprocessing (GP) tool to implement out-of-the-box logic to solve your problem. All you have to do is run the tool either in ArcMap, or programmatically using ArcObjects. The tool I think you are looking for is called Minimum Bounding Geometry, and the option you need to select is "Convex Hull." See the link below for details about how to use this tool in ArcMap: Minimum Bounding Geometry (Data Management) http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000003q000000 You will first need to convert your text representation of points into a point feature class (e.g. a shapefile). This will go into your GP tool as input. This Youtube video shows how to convert points in a CSV file containing X,Y coordinates into a Point Feature Class (Shapefile) in ArcMap. Of course, you can do this programmatically too; and it appears, you are already doing this in your own code above. Converting a table of Lat / Long values into a Shapefile https://www.youtube.com/watch?v=xk3b7l8EuIk To run a System Geoprocessing tool using ArcObjects, you have to write a bit of code. See below: How to run a geoprocessing tool http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/0001000003rr000000.htm You can call any geoprocesing tool this way, and avoid having to write ArcObjects code/logic from scratch (no need to re-invent the wheel). Many common problems have already been solved in ArcGIS Desktop; and all you need to do is find and call the GP tool, either in ArcMap, or using ArcObjects.
... View more
10-23-2015
11:54 AM
|
1
|
0
|
444
|
POST
|
Please post a snippet of the relevant code that shows the above scenario. Have you had a chance to read the following documentation on snapping using z-values and the Editor Snap Environment? Documentation on how to use ISnapEnvironment to snap using z-values: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/0001000003m3000000.htm Working with the Editor Snap Environment http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/0001000004s3000000.htm
... View more
10-22-2015
12:28 PM
|
0
|
0
|
245
|
POST
|
There are no methods in the ArcObjects API that would allow you to truncate a number to a specific number of decimal places without rounding it off. You would have to use methods found in the .NET API (which ArcObjects is built on top of). A Google search revealed the following solutions posted on other forums: Truncate Two decimal places without rounding http://stackoverflow.com/questions/3143657/truncate-two-decimal-places-without-rounding Truncating a number to specified decimal places https://social.msdn.microsoft.com/Forums/en-US/4cb1c454-df70-4649-b41f-a65bce070c85/truncating-a-number-to-specified-decimal-places?forum=netfxbcl I hope the above forum posts are useful.
... View more
10-22-2015
09:56 AM
|
0
|
0
|
251
|
POST
|
The ArcGISSOC account needs to have, at least, read access to the mxd and underlying data used in the map document.
... View more
10-14-2015
05:38 PM
|
0
|
0
|
343
|
POST
|
The issue of Cambodian font (Khmer Unicode) appearing with extra spaces between characters was identified as a bug in ArcGIS Desktop version 10.1 Service Pack 1 by ESRI Support via ESRI Thailand. A bug report was created, and the bug number is NIM085578. This defect is currently being worked on by ESRI.
... View more
10-14-2015
05:06 PM
|
0
|
0
|
428
|
POST
|
The following link from Microsoft might be of some help: How to dynamically add and run a VBA macro from Visual Basic https://support.microsoft.com/en-us/kb/219905 Just as an FYI, ESRI no longer supports VBA. Support for VBA stopped at ArcGIS version 10.0. Please migrate your VBA customizations to ArcObjects .NET (VB.NET or C#). The link below shows how this can be done. Migrating VBA customizations to ArcGIS 10.1 http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Migrating_VBA_customizations_to_ArcGIS_10/0001000000tv000000/
... View more
10-14-2015
04:50 PM
|
0
|
0
|
274
|
POST
|
The most probably cause of the problemfor your code becoming unresponsive is that it is not able to open the specified map document. This could be because it does not exist; the user logged in does not have permissions to read/write that folder location; or the map document is broken/corrupted. It should be noted that ESRI no longer supports VBA. Please migrate all your VBA customizations to ArcObjects .NET. You can choose between VB.NET and C#. Please give the following documentation a read to help with the migration: Migrating VBA Customizations to ArcGIS 10.1 http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Migrating_VBA_customizations_to_ArcGIS_10/0001000000tv000000/
... View more
10-14-2015
04:37 PM
|
0
|
0
|
164
|
POST
|
I created a new ArcMap Add-in based on your code and it worked just fine - the code was able to add a raster to the ActiveView in ArcMap. See below: protected override void OnClick() {
string dir = @"C:\Temp\RasterFolder\"; // The path to to directory containing the Tiff file
string varNh = @"Clipped_DEM_Israel.tif"; // Name of the Tiff File
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory");
IWorkspaceFactory wsFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IRasterWorkspace2 rasterWS = (IRasterWorkspace2)wsFactory.OpenFromFile(dir, 0);
IRasterDataset rds = rasterWS.OpenRasterDataset(varNh);
IRasterLayer rasterLayer = new RasterLayerClass();
rasterLayer.CreateFromDataset(rds);
IMap mapa = ArcMap.Document.FocusMap;
mapa.AddLayer(rasterLayer);
IActiveView activeView = mapa as IActiveView;
activeView.Refresh();
} I performed the test using ArcGIS 10.3.What version of ArcGIS were you using?
... View more
10-13-2015
03:05 PM
|
1
|
0
|
219
|
Title | Kudos | Posted |
---|---|---|
1 | 08-26-2016 02:26 PM | |
1 | 09-29-2015 04:24 PM | |
1 | 11-02-2015 06:25 PM | |
1 | 10-23-2015 12:27 PM | |
1 | 04-13-2015 05:41 PM |
Online Status |
Offline
|
Date Last Visited |
11-30-2023
04:20 AM
|