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

SDS Layer with Feature Service from ArcGIS Server in Engine C#

$
0
0
Hi :cool:

I've developed an application in ArcGIS Engine in C#.net that works perfectly with anything local (gdb, shape, raster, dwg)
and now I'm trying to get it working with ArcGIS Server layers etc.

trying to consume a Feature Service with Editing/Query/Create/Delete enabled.... the map control accepts the layer, and displays the data. "/SpatialDataServer/admin/services/Sandbox_TestLayer.FeatureServer/0"

however upon Query / add feature / edit, it seems the layer needs to be treated differently..
it edits and queries fine in ArcMap 10.1, so i'm just wondering how I need to cast the ILayer to be able to use it?

currently there's alot of conflicting information floating around, and I just need to know the right way to handle this.

I've looked into GISClient / MapServerLayer / AGSFeatureLayer ... but having trouble determining from the ILayer the "LayerType" i.e. if its from the server... / feature service layer.... any point in the right direction would be great.. as i'm new to this stuff..

I know its possible to consume it all through REST and geoJSON, but I'm assuming ESRI has a better way in ArcObjects to do this for me rather than me having to manually consume it all..

Tomas

ArcGIS 10.1, Delphi XE2 and licensing

$
0
0
Hi everyone,

We have a project on Delphi 5 and we need to upgrade it for Delphi XE2.
Everything went well until it came to the components of ArcGIS.
The problem is that I need to check the license for Desktop and Engine.
I found these two threads:
http://forums.arcgis.com/threads/262...-and-licensing

http://forums.arcgis.com/threads/605...-and-licensing

When including libraries ArcGISVersionLib_TLB, esriControls_TLB, esriSystem_TLB, ComObj I thought that everything would work but the project returns the following errors:

undeclared identifier TMapControl, TVersionManager, TAoInitialize

in the code:

public
{ Public declarations }
MapControl:esriControls_TLB.TMapControl;
verManager: arcGISVersionLib_TLB.TVersionManager;
aoInit: TAoInitialize;

any ideas?
Thanks beforehand.

ADF and ADF Local DLL

$
0
0
I need to use ComReleaser, BaseCommand and MxCommand.

The simple solution is to use ESRI.ArcGIS.ADF since it has these classes. However, the compiler complains:

Quote:

The type 'ESRI.ArcGIS.ADF.BaseClasses.BaseCommand' is defined in an assembly that is not referenced. You must add a reference to assembly 'ESRI.ArcGIS.ADF.Local, Version=10.1.0.0, ...
And if I add that reference, it complaints that I have duplicate:
Quote:

The type 'ESRI.ArcGIS.ADF.CATIDs.MxCommands' exists in both 'C:\Program Files (x86)\ArcGIS\DeveloperKit10.1\DotNet\ESRI.ArcGIS.ADF.Local.dll' and 'C:\Program Files (x86)\ArcGIS\DeveloperKit10.1\DotNet\ESRI.ArcGIS.ADF.dll'
How do I resolve this issue? Is there a way to explicitly specify which dll to load the class from?

Please help.

Bind combo box with data and display results

$
0
0
Dear all,

Currently, I am developing a simple application that contains 2 drop down lists, namely, products as well as price list.
The product drop down list has 4 options and how do I bind this drop down list with the values in the table so that I do not need to
pre-define the values. Additionally, this is also useful in the future because if there are new products, I can simply update the database
and the values will be automatically reflect in the drop down list.

I found a sample code that binds drop-down list with data from the database. Is this set of code suitable of for the web form in
arcGIS?

ddlProduct.DataSource = Product_Table
ddlProduct.DataSource.DataTextField = ‘Product_Name”
ddlProduct.DataSource.DataValueField = ‘Product_Name”
ddlProduct.Databind()

Second to retrive records from the database, I have generated a sql statement:
Secondly, the first field is mandatory while the price list is optional. This means the user can perform 2 types of search.
• Product
• Product + Price List

This is the SQL statement that I have generated:

Select * from Product_Table where Product_Name = “Printers” OR “ Scanners” OR “Laptops” AND Price_List = “100-200” OR “200-400” OR “400-600” OR “600-800” OR “800-1000” OR “”

How do i populate display results in data view because i tried to search for codes but cant find any

Thanks

Becky

update atribut

$
0
0
Hi,

I found a code like this:

==start code=============
Public Function InsertPoint(ByVal name As String, ByVal x As Double, ByVal y As Double, ByVal fld As String, ByVal fldval As String) As String
Dim sc As IServerContext = Nothing
Dim r As String
Try
Dim idt As ESRI.ArcGIS.ADF.Identity = New ESRI.ArcGIS.ADF.Identity("username", "password", "domain")
Dim agc As ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection = New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("server", idt)
agc.Connect()
Dim sm As IServerObjectManager = agc.ServerObjectManager
sc = sm.CreateServerContext("basemap", "MapServer")
Dim so As IServerObject = sc.ServerObject
Dim prop As IPropertySet = sc.CreateObject("esriSystem.PropertySet")

'connect to db
prop.SetProperty("SERVER", "svr-955")
prop.SetProperty("INSTANCE", "esri_sde")
prop.SetProperty("DATABASE", "reg_opt")
prop.SetProperty("USER", "sde")
prop.SetProperty("PASSWORD", "sde")
prop.SetProperty("VERSION", "sde.DEFAULT")
'prop.SetProperty("VERSION", "SDE.test")

Dim wsf As IWorkspaceFactory = sc.CreateObject("esriDataSourcesGDB.SdeWorkspaceFactory")
Dim fws As IFeatureWorkspace = wsf.Open(prop, 0)
Dim fc As IFeatureClass = fws.OpenFeatureClass(name)

If Not fc Is Nothing Then
If fc.ShapeType = esriGeometryType.esriGeometryMultipoint Or fc.ShapeType = esriGeometryType.esriGeometryPoint Then
Dim i As Integer = fc.FindField(fld)

'insert new object
If i > -1 Then
Dim frc As IFeatureCursor = fc.Insert(False)
Dim ft As IFeature = fc.CreateFeature()
Dim pnt As IPoint = sc.CreateObject("esriGeometry.Point")
pnt.X = x
pnt.Y = y
ft.Value(i) = fldval
ft.Shape = pnt
ft.Store()
r = "success"
Else
r = "error: field not found."
End If

Else
r = "error: data not point."
End If

Else
r = "error: data not found."
End If
sc.ReleaseContext()
Catch ex As Exception
r = "error:" & ex.Message
End Try
Return r
End Function

==end code=============

I want to replace the "insert new object" with "update existing object"

How can i achieve that ?

many many thanks

Save a Geometry (draw using Rubberband) as a feature in Feature Class

$
0
0
Namaste, Hola, Hi

Using the Code below I have created a Line geometry using Rubberbanding

public void DrawPolyline(ESRI.ArcGIS.Carto.IActiveView activeView)
{
if(activeView == null)
{
return;
}
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
rgbColor.Red = 255;

ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
simpleLineSymbol.Color = color;

ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberLineClass();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolyline(geometry);
screenDisplay.FinishDrawing();
}

After Drawing a Line geometry using Rubberband, I would like to save the "geometry" as a feature in a FeatureClass and create a Feature Layer and display the layer. I am facing trouble in creating feature class and saving a feature. Please help me with some sample Code .. I am badly waiting for some reply.

Thanks and Regards,
Pavan

Draw Line on MapControll

$
0
0
Hi. I try to draw line on map.

Code:

public static List<IPoint> pointness=new List<IPoint>();
 private void button1_Click(object sender, System.EventArgs e)
        {
            IPoint points = new PointClass();
            points.PutCoords(x, y);
            pointness.Add(points);
            ILine pLine1 = new LineClass();
            if (pointness.Count > 1)
            {
                for (var i = 0; i < pointness.Count - 1; i++)
                {
                    pLine1.PutCoords(pointness[i], pointness[i + 1]);
                }
            }
        }

I have List of points. Coordinates of point is coordinates of mouse, when it's click on map. To list points adds allright, but don't drawed.
Why? Maybe i set bad coordinates? I use coordinates like in Identify Tool.

Add an Index to a feature Class

$
0
0
Hi,
I want to add an index to a feature class. To do so, I use the very short and complete example given there:
http://resources.esri.com/help/9.3/a...35f906bb2e.htm

When I use this code, I obtain an exception due to a Castproblem:
It cannot cast from a IFeatureClass to a ISchemaLock:
Exception in thread "main" java.lang.ClassCastException: com.esri.arcgis.geodatabase.IFeatureClassProxy cannot be cast to com.esri.arcgis.geodatabase.ISchemaLock

Are you able to run this code sucessfully ?

You have to change the 2 first inputs in the code (the path and name of your shapefile)

Code:


import java.io.IOException;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;
import com.esri.arcgis.system.esriLicenseStatus;
import com.esri.arcgis.datasourcesfile.ShapefileWorkspaceFactory;
import com.esri.arcgis.geodatabase.Fields;
import com.esri.arcgis.geodatabase.IFeatureClass;
import com.esri.arcgis.geodatabase.IFeatureWorkspace;
import com.esri.arcgis.geodatabase.IField;
import com.esri.arcgis.geodatabase.IFields;
import com.esri.arcgis.geodatabase.IFieldsEdit;
import com.esri.arcgis.geodatabase.IIndex;
import com.esri.arcgis.geodatabase.IIndexEdit;
import com.esri.arcgis.geodatabase.ISchemaLock;
import com.esri.arcgis.geodatabase.IWorkspace;
import com.esri.arcgis.geodatabase.IWorkspaceFactory;
import com.esri.arcgis.geodatabase.Index;
import com.esri.arcgis.geodatabase.esriSchemaLock;


public class classmain
{
        public static void main(String[] args)
    {
           
            try
            {
            // >>> Enter here the path and the name of your shapefile.
            String folderPath = "D:\\ShapeFolder\\test";
            String shapefileName = "myShape_022";

            // Step 1: Initialize the Java Component Object Model (COM) Interop.
            EngineInitializer.initializeEngine();

            // Step 2: Initialize an ArcGIS license.
            AoInitialize aoInit = new AoInitialize();
            aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
       
            // Load the  ShapeFile into "featureClass"
            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
            IWorkspace workspace = workspaceFactory.openFromFile(folderPath, 0);
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            IFeatureClass featureClass = featureWorkspace.openFeatureClass(shapefileName);;

            // Find the field "FID" in featureClass that will be used as an index
            int fieldIndex = featureClass.findField("FID");
                       
            // Get the specified field from the feature class.
            IFields featureClassFields = featureClass.getFields();
            IField field = featureClassFields.getField(fieldIndex);
           
            // Create a new fields collection and add the specified field to it.
            IFields fields = new Fields();
            IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
            fieldsEdit.setFieldCount(1);
            fieldsEdit.setFieldByRef(0, field);
           
            //Create a new index and cast to the IIndexEdit interface.
            IIndex index = new Index();
            IIndexEdit indexEdit = (IIndexEdit)index;
           
            // Set the index's properties, including the fields it will have associated with it.
            indexEdit.setFieldsByRef(fields);
            indexEdit.setIsAscending(false);
            indexEdit.setIsUnique(false);
            indexEdit.setName("IndexFID");

            //Attempt to acquire an exclusive schema lock on the feature class.
            ISchemaLock schemaLock = (ISchemaLock)featureClass;
            schemaLock.changeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
            featureClass.addIndex(index);
            schemaLock.changeSchemaLock(esriSchemaLock.esriSharedSchemaLock);

            //  Disconnect licences
            aoInit.shutdown();
        }
        catch (IOException ex)
        {
            System.out.println(ex.getMessage());
            System.out.println("App failed.");
        }
    } //End of method main.
} //End of class:EngineHelloWorld.


How to fire an edit event?

$
0
0
Hello,

I know how to listen to edit events, but I would like to fire an edit event myself. Does anyone know how to do this?
I tried the following (in C#):

Code:

UID editorUid = new UIDClass();
editorUid.Value = "esriEditor.Editor";
IEditor editor = _app.FindExtensionByCLSID(editorUid) as IEditor;

IEditEvents editEvents = editor as IEditEvents;
if (editEvents != null)
{
    editEvents.OnCurrentLayerChanged();
}

However, the QI from IEditor to IEditEvents doesn't work, editEvents is null.

Thanks,
Barbara

Start up question

$
0
0
I am new to ArcObjects SDKs am i am using Window 7 , 64 bit system, Visual studio 2010 and dot net platform 4.0 and when I try very simple code it gives following error.

Retrieving the COM class factory for component with CLSID {00A5CB41-52DA-11D0-A8F2-00608C85EDE5} failed due to the following error: 80040111 ClassFactory cannot supply requested class (Exception from HRESULT: 0x80040111 (CLASS_E_CLASSNOTAVAILABLE)).

Any help will be appreciated.

ARCGIS add-in using .NET

$
0
0
I am using ARCGIS10.1. I have used Python add-in in ARCMAP 10.1 ,however now i wish to create add-in using .NET, I want to know how to start . I mean is the same like Python or should i need to install some thing else. Any suggestion is appreciated.

what is the difference between new Point and new PointClass

$
0
0
Dear Developers,
I am extending ArcObject with .NET. I am not sure what is the difference between the following two sentences:

Dim pt as IPoint = new Point
Dim pt2 as IPoint = new PointClass

From the intelisense prompt I can only see Point but not PointClass. In this case, do I have to add Class manually every time I define new CoClass? That will be painful. Also, when I use new Point, it works without any problem.

Thanks for your clarification,

Hailiang

ARCGIS Add-in time slider window

$
0
0
I know Time slider window in toolbar of arcmap is used to display time enabled data in the layer. However for one of my application i wish to write a Add-in using DotNet (through c sharp in visual studio 2010) which may be able to activate this Time slider window through my created add in . in other words i want to know is there any way we can use Time slider window in user created add in through coding. Any help is appreciated.
regards
nadeem

Implementing persistence of a symbol in an AddIn

$
0
0
Hey there,

I would like my map document to save a user chosen symbol. Therefore I want to implement persistence in my AddIn. There is an example in ArcObjects 10.1 Help, which is unfortunately missing an important piece: PersistHelper class. Does anybody have an example of persisting custom types in AddIns?

Thanks and best regards
S. Reuther



http://resources.arcgis.com/en/help/...00000zz000000/

Quote of help content:

[... To store custom types and object graphs, use the ArcObjects PersistHelper class. The following code example shows an extension writing a private struct, which manages an ArcObjects type:[C#]private MyPersistentData _data;

protected override void OnLoad(Stream inStrm)
{
// Initialize the struct.
_data.Location = "";
_data.Point = new ESRI.ArcGIS.Geometry.PointClass();

PersistHelper.Load < MyPersistentData > (inStrm, ref _data);
}

protected override void OnSave(Stream outStrm)
{
PersistHelper.Save < MyPersistentData > (outStrm, _data);
}

[Serializable()]
private struct MyPersistentData
{
public string Location;
public ESRI.ArcGIS.Geometry.PointClass Point;
} ...]

Automation Exception:Item Not Found in this Collection. in 'DAO.Fields'

$
0
0
Hi,

Can any one please let me know like whether the this query is supported over Feature Class which is got from the File GeoDatabase?

What I am trying to do is, I am making the query over the Feature Class which is got from File Geo Database. I am trying with the query as which contains the "ORDER BY" clause. I am getting the following exception.

Automation Exception: Item Not Found in this Collection. in 'DAO.Fields'.

Can any one please let me know whether "Order by" is support by the File Geo DataBase. I checked with the database fields I am using with my query. It is perfectly correct. BTW, I am trying all this process programmatically using Java.

Any Help is much appreciated.

Thanks in Advance.

Automation Exception:Item Not Found in this Collection. in 'DAO.Fields'

$
0
0
Hi,

Can any one please let me know like whether the this query is supported over Feature Class which is got from the File GeoDatabase?

What I am trying to do is, I am making the query over the Feature Class which is got from File Geo Database. I am trying with the query as which contains the "ORDER BY" clause. I am getting the following exception.

Automation Exception: Item Not Found in this Collection. in 'DAO.Fields'.

Can any one please let me know whether "Order by" is support by the File Geo DataBase. I checked with the database fields I am using with my query. It is perfectly correct. BTW, I am trying all this process programmatically using Java.

Any Help is much appreciated.

Thanks in Advance.

cast from IFeatureClass to ISchemaLock (ARCGIS)

$
0
0
Hi

I'm programming with the ARCGIS Java SDK, in Eclipse.

I need to cast an IFeatureClass to an ISchemalock. This cast is supposed to be allowed. There is an example of this cast in: http://resources.esri.com/help/9.3/a...35f906bb2e.htm

However, when I try to perform this cast in my code, an exception appears:

Exception in thread "main" java.lang.ClassCastException: com.esri.arcgis.geodatabase.IFeatureClassProxy cannot be cast to com.esri.arcgis.geodatabase.ISchemaLock

Are you able to make this cast on an IFeatureClass ? Here is the code to perform this:
Code:

//Attempt to acquire an exclusive schema lock on the feature class.
ISchemaLock schemaLock = (ISchemaLock)featureClass;

I would appreciate if you could try this simple line of code in one of your programs, and let me know if you get an exception.

Keep me posted...

Retrieve Table Datasource Type

$
0
0
I'm trying to get at the data source type of a table in the Table of contents. I usually do this with Feature Layers which is as simple as featureLayer.DataSourceType. The ITable interface has no such property. I can't seem to get at the Table as a Layer. Is there some casting I'm not doing properly? I see the IDataSourceInformation Interface. Is that something I can use?

Any help is appreciated. If you'd like to see code I'll reply. I just need to know which objects to use.

-Corbin de Bruin

Migration from 10 to 10.1

$
0
0
I am relatively new to using the ArcGIS libraries, so forgive me if this is off target.

Apparently the historical approach is to move client installs to the latest ArcGIS, and then the SDE server at a later date.

Hence, at the moment, we've moved our client code base to run against 10.1, connect to a 10.1 Licence Server, but connect to the 10 SDE database.

I've updated the C# code to reference the 10.1 assemblies, compiles ok, however when running I get a COMException "The operation was attempted on an empty geometry" (PointClass).

Should I be able to run as described (client 10.1, Licence Server 10.1, SDE 10)?

Or do I need to migrate code as part of the move from 10 to 10.1?

Thanks

Using png for PictureMarkerSymbol

$
0
0
By the docs you can create PicyureMarkerSymbol from bmp and emf files only.
Is there a way to create PictureMarkerSymbol from png file?

Thanks
Mody
Viewing all 1374 articles
Browse latest View live