Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all 1374 articles
Browse latest View live

Set Spatial Reference for a a XY event source layer

$
0
0
I have an XY event source layer, added to ArcMap with the option File > Add Data > Add XY Data, but when trying to change the spatial reference of this layer with ArcObjects I get a E_NOINTERFACE error.

The code snippet that manages the change of the spatial reference is like:

Code:

Dim spatialRef As ISpatialReference = ...
Dim geoDataset As IGeoDataset = fl.FeatureClass

Dim geoDatasetSchemaEdit As IGeoDatasetSchemaEdit = geoDataset
If (geoDatasetSchemaEdit.CanAlterSpatialReference) Then
        geoDatasetSchemaEdit.AlterSpatialReference(spatialRef)
End If

Previous code works fine for other type of layers. Also from the ArcMap UI is possible to change the spatial reference of an XY event source layer, so I guess should be possible with ArcObjects.

I found these related posts: http://forums.arcgis.com/threads/746...nterface-error and http://forums.arcgis.com/threads/760...tial+reference, but didn't succeed.

Any idea how can be change the spatial reference of XY event source layers with ArcObjects?

Thanks in advance.

Problem with IWorkspaceEdit in Arcobjects 10.2

$
0
0
I'm trying to edit a IWorkspaceEdit using the StartEditing(True) method with ArcObjects 10.2 (SDE & PostreSQL 9.2.2).

The problem is than an error is raised with the following message: "The method or operation is not implemented.".

Any hint ?

How can i get IApplication object.

$
0
0
hello,everyone:
How can i get IApplication object,i use c#
my class extends the ESRI.ArcGIS.ADF.BaseClasses.BaseCommand.
i use the way below in the OnCreate(object hook) method;
when i use:
IApplication pApplication = hook as IApplication;
the pApplication will be null.
and when i use:
IApplication pApplication = (IApplication)hook;
will throw exception, the hook object cannot convert to IApplication;

How can i get IApplication object,someone who can help me,very thank you.

how to find layer type of a layer

$
0
0
How do I find a layer type of an ILayer? For example, if I loop through all ILayers from an IMap, how do I determine whether each ILayer is an IGroupLayer ?

I already know I can use IMap.get_Layers(<IUID>, true) to obtain all the layers of a given type according to the passed IUID.

But I prefer to first obtain all layers, then determine what type of layer it is.

what's the difference between a layer's CLSID, GUID, and UID

$
0
0
Using the code snippet below, I'm confused about the terms CLSID, GUID, and UID in respect to layer objects.

Are they all the same thing?


///<summary>Stub code to loop through layers in a map where a specific UID is supplied.</summary>
///
///<param name="map">An IMap interface in which the layers reside.</param>
///<param name="layerCLSID">A System.String that is the layer GUID type. For example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" is the IGeoFeatureLayer.</param>
///
///<remarks>In order of the code to be useful the user needs to write their own code to use the layer in the TODO section.
///
/// The different layer GUID's and Interface's are:
/// "{AD88322D-533D-4E36-A5C9-1B109AF7A346}" = IACFeatureLayer
/// "{74E45211-DFE6-11D3-9FF7-00C04F6BC6A5}" = IACLayer
/// "{495C0E2C-D51D-4ED4-9FC1-FA04AB93568D}" = IACImageLayer
/// "{65BD02AC-1CAD-462A-A524-3F17E9D85432}" = IACAcetateLayer
/// "{4AEDC069-B599-424B-A374-49602ABAD308}" = IAnnotationLayer
/// "{DBCA59AC-6771-4408-8F48-C7D53389440C}" = IAnnotationSublayer
/// "{E299ADBC-A5C3-11D2-9B10-00C04FA33299}" = ICadLayer
/// "{7F1AB670-5CA9-44D1-B42D-12AA868FC757}" = ICadastralFabricLayer
/// "{BA119BC4-939A-11D2-A2F4-080009B6F22B}" = ICompositeLayer
/// "{9646BB82-9512-11D2-A2F6-080009B6F22B}" = ICompositeGraphicsLayer
/// "{0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E}" = ICoverageAnnotationLayer
/// "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}" = IDataLayer
/// "{0737082E-958E-11D4-80ED-00C04F601565}" = IDimensionLayer
/// "{48E56B3F-EC3A-11D2-9F5C-00C04F6BC6A5}" = IFDOGraphicsLayer
/// "{40A9E885-5533-11D0-98BE-00805F7CED21}" = IFeatureLayer
/// "{605BC37A-15E9-40A0-90FB-DE4CC376838C}" = IGdbRasterCatalogLayer
/// "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer
/// "{34B2EF81-F4AC-11D1-A245-080009B6F22B}" = IGraphicsLayer
/// "{EDAD6644-1810-11D1-86AE-0000F8751720}" = IGroupLayer
/// "{D090AA89-C2F1-11D3-9FEF-00C04F6BC6A5}" = IIMSSubLayer
/// "{DC8505FF-D521-11D3-9FF4-00C04F6BC6A5}" = IIMAMapLayer
/// "{34C20002-4D3C-11D0-92D8-00805F7C28B0}" = ILayer
/// "{E9B56157-7EB7-4DB3-9958-AFBF3B5E1470}" = IMapServerLayer
/// "{B059B902-5C7A-4287-982E-EF0BC77C6AAB}" = IMapServerSublayer
/// "{82870538-E09E-42C0-9228-CBCB244B91BA}" = INetworkLayer
/// "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}" = IRasterLayer
/// "{AF9930F0-F61E-11D3-8D6C-00C04F5B87B2}" = IRasterCatalogLayer
/// "{FCEFF094-8E6A-4972-9BB4-429C71B07289}" = ITemporaryLayer
/// "{5A0F220D-614F-4C72-AFF2-7EA0BE2C8513}" = ITerrainLayer
/// "{FE308F36-BDCA-11D1-A523-0000F8774F0F}" = ITinLayer
/// "{FB6337E3-610A-4BC2-9142-760D954C22EB}" = ITopologyLayer
/// "{005F592A-327B-44A4-AEEB-409D2F866F47}" = IWMSLayer
/// "{D43D9A73-FF6C-4A19-B36A-D7ECBE61962A}" = IWMSGroupLayer
/// "{8C19B114-1168-41A3-9E14-FC30CA5A4E9D}" = IWMSMapLayer
///</remarks>
public void LoopThroughLayersOfSpecificUID(ESRI.ArcGIS.Carto.IMap map, System.String layerCLSID)
{
if(map == null || layerCLSID == null)
{
return;
}
ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
uid.Value = layerCLSID; // Example: "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}" = IGeoFeatureLayer
try
{
ESRI.ArcGIS.Carto.IEnumLayer enumLayer = map.get_Layers(((ESRI.ArcGIS.esriSystem.UID)(uid)), true); // Explicit Cast
enumLayer.Reset();
ESRI.ArcGIS.Carto.ILayer layer = enumLayer.Next();
while (!(layer == null))
{
// TODO - Implement your code here...
layer = enumLayer.Next();
}
}
catch (System.Exception ex)
{
//System.Windows.Forms.MessageBox.Show("No layers of type: " + uid.Value.ToString);
}
}

Obtain the layer ID of an ILayer

$
0
0
Hi, what's the best way to obtain the layer ID of an ILayer?

The information below might be confusing, but I just want to provide background as to why I'm asking this question...

The closest thing I found was ILayerDescriptor.ID . But it seems you need a Map Service object to obtain the ILayerDescriptor--all I have is an mxd document.

I guess I could loop through all layers, and just increment an integer starting from 0, and assume that the layer ID will be the same as the integer. But that seems kinda quirky.

License level requirements for add-in deployment

$
0
0
Hello,

I am running Advanced (ArcInfo) and I am developing an add-in that will be deployed to multiple computers around the company. We need to know what license level each machine should be running. Is there a way to determine if an add-in will work on a computer with a lower license level, without physically installing and trying every possible function of the add-in on the target machine to see if it will fail? Will an add-in developed in Advanced run in Standard?

Thanks,
Evan

Editing Config.esriaddinx with the Wizard

$
0
0
I created an add-in toolbar some time ago (10.1) with menus and submenus. And now I am trying to make edits to this toolbar, but I can't recall how to edit the Config.esriaddinx file? Is there a way to re-launch the ArcGIS Add-Ins Wizard to edit this file so that I don't have to touch the raw XML? Thanks.

Converted GDE to SDE and GPServices now cannot open

$
0
0
We just completed converting our data from a filebased GDE "database" to an SDE on SQL Server.
We changed our code to grab the connection string, changed our usage from IWorkspaceFactory to IWorkspaceFactory2, and call OpenFromString to get to the SDE database.

When we compile and open our services in ArcMap (in preparation for publishing them as a GPService) the services will not open. This is symptomatic of Arcmap unable to find the schemas specified in the database. This was proven by the ability to open the one service call that just takes an integer as a parameter. (no schema access needed)

I saw the all of the schema names changed from {schema name} to {server name}.DBO.{schema name} so changed all of the code to specify the new schema names in the database. However that hasn't changed anything at all. Nothing opens.

What must we do to get our services changed and running under an SDE database and published?

Using a GPServer in .NET application

$
0
0
I have a GPServer that exports a PDF using an MXD as an input.

http://myserver/arcgis/rest/services...ToPDF/GPServer

I would like to call it from a .NET ArcGIS Server 10.2.2 SOE but can't find any code examples.

I can use an HTTP WebRequest to execute the GPServer but I wanted to see if there were any ArcObjects Geoprocessor ways to do it.

Please let me know if anyone has some exmaples to share.


Thanks,

Mele

Create feature and get access to the archive id

$
0
0
Hi,

I want to create a feature on a versioned geodatabase with archiving enabled and have access to the exact gdb archive id associated with the feature. Is this possible?

I know that from the IFeatureClass I can access the associated archived table via IArchivableClass.Archive.
However, I am not sure whether an UpdateCursor referencing the archived table would be ideal to set the IFeature properties ...

Cheers,
Jose

arcgis application which publishes a map on arcgis server

$
0
0
Hello Community !

I'm new into ArcGIS / ArcGIS developers. I am running on Windows 7, Visual Studio .NET 2012. I program in C#. I would be interested in creating a simple application which would take as input a map and then publish it on the ArcGIS Server which would expose it to world. Its my first project, so I don't know where to start from. Can you point me what sort of ArcGIS project should I start or a simple "Hello World" application for my task?

Thanks,
Duktech.

FEATURE ATTRIBUTE TABLE COMPARE

$
0
0
HELLO ALL

I AM NEW TO c#.NET ARCOBJECTS DEVELOPMENT.

I NEED TO CREATE A TOOL WHICH COMPARE TWO SIMILAR TYPE OF SHAPE FILE. ONE IS OLD AND ONE IN UPDATED.
TOOL SHOULD REPORTS WHAT COLUMN HAS BEEN UPDATED FOR EVERY FEATURE.

CAN SOMEBODY HELP ME WITH THIS ??
Attached Files

What does the IDockableWindow.UserData Property actually return?

$
0
0
ESRI/ArcObject Gurus.

I have developed a dockable window as an AddIn using VB .Net. When you use the Wizard to create the AddIn it creates a UserControl which one populates with drop downs, text boxes etc. This all works fine.

I have created a COM object so this compiles to a separate DLL which is referenced by MS Access. This COM object starts an instance of ArcMap and needs to pass a value from an Access form to a textbox on the Dockable Window. I can get a handle on the window using the IDockableWindowManager.GetDockableWindow Method but I can't figure out how to drill down to the Textbox. Presumably its via the UserData property? If I get the object returned by this property and run it through TypeName function it simply says its IUnknown.

Various threads on the forum and searches point to this blog. But this method requires you to be able to access the AddIn so you are running code within the ArcMap framework. The Addin is a file only understood by ArcMap and not something that MS Access can reference.

So my question is what is the object returned by UserData property, the help page on this topic is decidedly unhelpful?

Has anyone worked out how to cast what ever it returns into a usercontrol where you can drill down to the various controls on it?

I very much look forward to any advice on this as I have hit the "wall".

add AnnotationLayer to map

$
0
0
I have a FileGeoDatabase with a AnnotationFeatureClass (within 3 AnnotationClasses) that I programmatically want to load to my map. First I load the FeatureClass in order to get some Informations and then while creating the AnnotationLayer an error occurs. I've used some code from the Esri-help, but what could be wrong?
Code:

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
                        IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
                        ws = workspaceFactory.OpenFromFile(pGdbSource.Dir + "\\" + pGdbSource.File, 0);
               
                if (ws != null)
                {
                        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)ws;
                        IFeatureLayer featureLayer = new FeatureLayerClass();
                        string FCName = (pGdbSource.BrowseName != "") ? pGdbSource.BrowseName : pGdbSource.ItemName;
                        featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(FCName);
                        ILayer layer = (ILayer)featureLayer;
                        if ((featureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) &&
                            (featureLayer is FeatureLayerClass))
                        {
                            // Get the GeometryDef from the feature class's shape field.
                            String shapeFieldName = featureLayer.FeatureClass.ShapeFieldName;
                            int shapeFieldIndex = featureLayer.FeatureClass.FindField(shapeFieldName);
                            IFields fields = featureLayer.FeatureClass.Fields;
                            IField shapeField = fields.get_Field(shapeFieldIndex);
                            IGeometryDef geometryDef = shapeField.GeometryDef;

                            IAnnotateLayerPropertiesCollection annotateLayerPropsCollection = (featureLayer as FeatureLayerClass).AnnotationProperties;

                            // Create a graphics layer scale object.
                            IGraphicsLayerScale graphicsLayerScale = new GraphicsLayerScaleClass();
                            try
                            {
                                graphicsLayerScale.ReferenceScale = mxDocument.ActiveView.FocusMap.MapScale;
                            }
                            catch (Exception ex) { graphicsLayerScale.ReferenceScale = 0.0; }
                            graphicsLayerScale.Units = mxDocument.ActiveView.FocusMap.MapUnits;

                            // Create the overposter properties for the standard label engine.
                            IOverposterProperties overposterProperties = new BasicOverposterPropertiesClass();

                            ISymbolCollection symbolCollection = new SymbolCollectionClass();
                            ISymbolCollection2 symbolCollection2 = (ISymbolCollection2)symbolCollection;

                            // Create the annotation layer factory.
                            IAnnotationLayerFactory annotationLayerFactory = new FDOGraphicsLayerFactoryClass();

                            IDataset pDataset = (featureLayer as FeatureLayerClass) as IDataset;

                            // Create the annotation feature class and an annotation layer for it.
                            IAnnotationLayer annotationLayer = annotationLayerFactory.CreateAnnotationLayer
                                (featureWorkspace, pDataset as IFeatureDataset, FCName,
                                geometryDef, null,
                                annotateLayerPropsCollection, graphicsLayerScale, symbolCollection, false,
                                false, false, true, overposterProperties, "configKeyword");

                            // Get the feature class from the feature layer.
                            featureLayer = (IFeatureLayer)annotationLayer;

Thanks for any suggestions!

ESRI AddIn and Excel instance problem

$
0
0
Good morning. I have a programing question related to ArcGIS and Excel.

We are developing an AddIn that creates and opens a report in Excel. We want to open the report using, if one is already running, an existing running instance of Excel. If there is not one running, then start one. Currently we are getting mix results. The code that implements this logic is:

public Microsoft.Office.Interop.Excel.Application InitExcel(string macroName)
{
Microsoft.Office.Interop.Excel.Application exApp = null;
Microsoft.Office.Interop.Excel.Workbook openWrkbk = null;
Microsoft.Office.Interop.Excel.Workbook exWbk = null;

try
{
//Determine if there is an open instance of Excel running. If so, we will
//open the results in the same application. Otherwise, start a new
//instance of Excel.
try
{
//First, kill any hung instances of Excel--ones that have no window.
Process[] processlist = Process.GetProcessesByName("Excel"); //Shows number of running Excel apps
foreach (Process theprocess in processlist) //foreach Excel app running
{
if (theprocess.MainWindowHandle.ToInt32() == 0)
try
{
theprocess.Kill();
}
catch { }
}
try
{
Here: exApp = (Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
}
catch (Exception err)
{
Tohere: MessageBox.Show("exception from marshal.getactiveobject " + err.ToString()); // ERROR EVERY TIME ON FIRST CALL
}
if (!exApp.Visible)
{
exApp = new Microsoft.Office.Interop.Excel.Application();
}
}
catch
{
exApp = new Microsoft.Office.Interop.Excel.Application();
}

The line labeled “Here:” is the line that checks to see if excel is already running. It should return null or an Excel application object. The first time it is called, it throws and exception every time. To be specific, this exception Attachment 34333

The addin then goes on to start a new instance of Excel, and in subsequent calls to InitExcel, the call to marshal.getobject returns an Application Object that references this 2nd instance of excel.

I’ve written a test program that does this same exact thing, in the same way. It’s just a simple standalone desktop application. I click a button; it makes the call to marshal.getactiveobject. I cannot make it throw an exception; it behaves as expected. If excel is already running, it returns an object that references that instance of excel. If excel is not running, it returns null.

This makes me think that somehow, ArcMap is turning off an rpc service, or otherwise “blocking” the addin code from marshaling somehow. Any ideas or thoughts would be greatly appreciated.

Thank you
Attached Thumbnails
Click image for larger version

Name:	ExcelError.jpg‎
Views:	N/A
Size:	35.5 KB
ID:	34333  

IXMLPropertySet2.SaveAsFile XSL Translate Error

$
0
0
Hi everyone, I'm stuck on this issue and really unsure what the problem is.

I am trying to simply save the (IXMLPropertySet2)IMetadata.Metadata using the IXMLPropertySet2.SaveAsFile() method with the following code:

Code:

metadataToolControlVM.CurrentMetadata.SaveAsFile("C:\\Program Files (x86)\\ArcGIS\\Desktop10.2\\Metadata\\Translator\\ARCGIS2FGDC.xml", "", false, "C:\\Temp\\test.xml");
Which produces the following error when that code is called:

An exception of type 'System.Runtime.InteropServices.COMException' occurred in ArcCatalog_MetadataTool.dll and wasn't handled before a managed/native boundary

Additional information: Namespace 'urn:schemas-microsoft-com:xslt' does not contain function 'utc'.


As far as I can tell from this microsoft site, it should in fact contain the utc function.

I have been spinning my wheels on this for a while now, I can't see what's wrong here. Anyone able to offer insight?

.ecfg file name

$
0
0
I'm generating some .ecfg files using post build events in my projects. I'm using .NET 4.5 and Visual Studio 2012. My file names are in the following format:
{<guid_id>}_<nameOfClass>.ecfg
But I noticed that most of the other ones are just <nameOfClass>.ecfg

I didn't see anything in ESRIRegasm.exe to name mine <nameOfClass>.ecfg.
How do I do this?

Getting ArcGIS Service Pack and Build numbers in ArcObjects

$
0
0
Hi again,

I am looking to get the Service Pack and Build numbers through ArcObjects.

So far I can get the major version number using
Code:

RuntimeManager.ActiveRuntime.Version;
This returns "10.2" - but the requirements for what I'm working on want more specific information than that.

I also saw this post on gis.stackexchange that states you can look up the service pack number based on the version number returned by
Code:

Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion;
However this returns "11.0.50727.1" which does not correspond in any way to the list that they reference in that post.

There is arcpy functionality in arcpy.GetInstallInfo() that is able to return these values, so I know it's got to exist in ArcObjects somewhere. Any ideas?

how to find out if values are grouped in IUniqueValueRenderer

$
0
0
Hi, I trying to use IUniqueValueRenderer.get_Symbol(value) . The reference says to pass the value when there's no grouping. When there's grouping, you pass the reference value. How do you find out if values are grouped or not?

I tried to use IUniqueValueRenderer.get_ReferenceValue(value), thinking it would return null when there's no grouping, but it actually throws an exception.

I guess I could catch the exception and use that to indicate whether there's grouping or not, but that's an inappropriate use of an exception.

suggestions?
Viewing all 1374 articles
Browse latest View live