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

How to sort items in combobox?

$
0
0
Hi Everyone,

I want to ask spesific question about sorting items in combobox from A to Z. How can i perform sorting them?

If i cant sort them A to Z there is meaningless about the query that will be applied on it.

Waiting forward for your replies, kindly regards.

Tolga

Here are my vba codes:

Private Sub UserForm_Initialize()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFeatLayer As IFeatureLayer
Dim pFeatClass As IFeatureClass
Dim pFields As IFields
Dim pField As IField
Dim i As Integer

Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pFeatLayer = pMap.Layer(0)
Set pFeatClass = pFeatLayer.FeatureClass
Set pFields = pFeatClass.Fields

For i = 0 To pFields.FieldCount - 1
cboMusteri.AddItem pFields.Field(i).Name


Next

Dim pLayer As ILayer
Set pLayer = pMap.Layer(0)
Set pFeatLayer = pLayer
Dim pFeature As IFeature
Dim pFeatCursor As IFeatureCursor
Dim pQueryFilter As IQueryFilter
Set pQueryFilter = New QueryFilter
pQueryFilter.SubFields = "MALIK"
Set pFeatCursor = pFeatLayer.Search(pQueryFilter, True)
Set pFeature = pFeatCursor.NextFeature

Dim j As Integer
Dim cDuplicate As Boolean
cDuplicate = False

cboMusteri.Clear

Do While Not pFeature Is Nothing
For j = 0 To cboMusteri.ListCount - 1
cDuplicate = False
If cboMusteri.List(j) = pFeature.Value(pFeature.Fields.FindField("MALIK")) & "" Then
cDuplicate = True
End If
Next j

If cDuplicate = False Then
cboMusteri.AddItem pFeature.Value(pFeature.Fields.FindField("MALIK")) & ""
End If
Set pFeature = pFeatCursor.NextFeature

Loop

Set pFeatCursor = Nothing
Set pFeature = Nothing
Set pFeatLayer = Nothing
Set pLayer = Nothing
Set pMap = Nothing
Set pMxDoc = Nothing
End Sub

identify tool in c#

$
0
0
I am using ARCObject SDK 10.1. In one of my application i want that when user clicks map layer than i can read the data assoicated to the attribute table of the layer at the clicked point. I know identify tool does this job in arc map. I want the similar function without displaying the identify tool dialog box. I would appreciate ant hint or direction to start with. how to execute a query from c sharp to reterive the data from the assoicated attribute table of the layer.
regards
nadeem

buffer in ARCObject

$
0
0
I am using ARCobject SDK 10.1 under visual studio Csharp. In one of my application i want to apply the buffer operation on an layer. I have used the buffer operation in ARCMap tool box but do nt know how to do this in ARCObject. Please note that my requirement is that i want to use input features as points based on mouse click on the map and its map points will be passed as input features to buffer the layer for a given distance.
Please any help as i am trying hard without any success.

spatial query based on mouse click event

$
0
0
Please look the code , I wish to access the feature at the mouse coordinate on mouse click event. however my code below return all the records rather than a single point. any guess what is wrong.

IMxApplication pMxApp = null;
pMxApp = (IMxApplication)ArcMap.Application;
IMxDocument pMxDoc = null;

pMxDoc = ArcMap.Document;
if (pMxDoc.SelectedLayer == null)
{
MessageBox.Show("There is no layer selected. First select a time-aware layer.");
return;
}
IMap pMap = pMxDoc.FocusMap;
IFeatureLayer feature_layer = (IFeatureLayer)pMap.get_Layer(0);// put the index of ur lauer
IPoint point = new PointClass();

x = pMxDoc.CurrentLocation.X; // this is point returns when user click on mouse.
y = pMxDoc.CurrentLocation.Y;
MessageBox.Show(x+ ":" + y);
point.PutCoords(x, y);
// point.PutCoords(280, 240);
point.SpatialReference = pMap.SpatialReference;
ISpatialFilter spatial_filter = new SpatialFilterClass();
spatial_filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
spatial_filter.Geometry = point;
spatial_filter.GeometryField = feature_layer.FeatureClass.ShapeFieldName;
MessageBox.Show(spatial_filter.GeometryField.ToString());
IFeatureCursor feature_cursor = feature_layer.FeatureClass.Search(spatial_filter, false);
IFeature feature = feature_cursor.NextFeature();

while (feature != null) // here it returns the whole records rather than single point.
{
// do what u wan0t with the feature
MessageBox.Show(feature.get_Value(3).ToString());
feature = feature_cursor.NextFeature();
}
}


}

Workspace Extension to make table invisible to user

$
0
0
Hello!

We have growing need to implement a scenario where user can't see specific table in a workspace, but - via our Arcmap class library - is able to insert rows to the table; that is done programmatically and is generally unobservable process to the user.

Firstly - is it possible to do so?

Secondly, it seems that the proper solution would be to build workspace extension by using PrivateDatesetNames property.
But I have problem defining a suitable ENUMBSTR class for that (in VB.NET). This one is what I have:

Code:

Public NotInheritable Class MyEnumBSTR
    Implements IEnumBSTR
    Private _index As Integer = 0
    Private _strings As New List(Of String)()
    Private Const S_FALSE As Integer = 1

    Public Sub Add(ByVal strVal As String)
        _strings.Add(strVal)
    End Sub
    Public Sub New(ByVal tbls As String())
        For Each str As String In tbls
            Add(str)
        Next

    End Sub
    Public Sub Reset() Implements IEnumBSTR.Reset
        _index = 0
    End Sub
    Public Function [Next]() As String Implements IEnumBSTR.Next
        If _index > _strings.Count Or _index < 1 Then
            [Next] = ""
            Err.Raise(S_FALSE)
        Else
            [Next] = _strings.Item(_index)
            _index = _index + 1
        End If
    End Function
End Class

...and property in my extension class:
Code:

    Public ReadOnly Property PrivateDatasetNames(ByVal datasetType As esriDatasetType) As IEnumBSTR _
    Implements IWorkspaceExtension.PrivateDatasetNames, IWorkspaceExtension2.PrivateDatasetNames
        Get
            Dim hiddenTables() As String = New String() {"table1"}
            Dim enumBSTR As IEnumBSTR = CType(New MyEnumBSTR(hiddenTables), IEnumBSTR)
            Return enumBSTR
        End Get
    End Property

Now, I have made sure that this extension is really registered for a certain .gdb geodatabase and even MyEnumBSTR.Add method has been called... but I still can see that table in ArcCatalog and in ArcMap.

Is there something that I have somehow looked over?

Best regards,
Raivo Alla,
Estonian Land Board

Getting Access to Feature Classes in File GDB without a Dataset?

$
0
0
I've got a script that works with many different forms of File GDBs. Sometimes they have datasets and sometimes they dont. For the ones that have datasets, I have the working code:

Code:

C#
IWorkspaceFactory wsFact = new FileGDBWorkspaceFactoryClass();
IWorkspace ws = wsFact.OpenFromFile(database, 0);
IEnumDataset enumDS = ws.get_Datasets(esriDatasetType.esriDTFeatureDataset);
IFeatureDataset ds = (IFeatureDataset)enumDS.Next();
IEnumDataset enumFC = ds.Subsets;
IDataset currFC = enumFC.Next();
FeatureClass fc = (FeatureClass)currFC;

But, when the database doesn't have a dataset and it hits the 5th line it throws an error since enumDS.Next() is null. I've tried to chance the esriDatasetType to esriDTFeatureClass, but that doesn't work. I've also tried using the GeoProcessor (which I would prefer not to), but the ListFeatureClasses returns a blank string.

I'm sure this has a simple solution, but I just cannot find it.

intersection points of polygon and polilyne

$
0
0
Sorry for my bad English.

How I can to get intersection points of polygon and polilyne?
I tried to use ITopologicalOperator.intersect and ITopologicalOperator2.IntersectMultidimension methods, but
the methods have returned points of ends of polilyne, but not intersection points.

5 Combobox to Select By Attributes From Joined Table

$
0
0
Hi Experts,

I created 6 combobox including attributes of joined data. I want to make a query like "select by attribute" by using the comboboxes.

I used many of the sample codes but I got some errors.

Can you help me about finding solutions to write a codes for querying like select by attribute function?

Note: I have another userform to select by attributes by using one of the fields on same layer.

I just want to use AND function to select attributes and in sixth combobox will choose null values or others to zoom after five combobox's choosen data.

I hope i would be clear enough.

Kindly Regards.

Add-In says "Missing" - DLL did not install

$
0
0
Hello all,

When my 10.1 Add-In is installed on a client's machine, it does not show up properly. It says "Missing" on the toolbar and clicking the button does absolutely nothing. When I check the user's AssemblyCache, I only see the .pbd and .xml files. The DLL isn't writing. I'm not getting errors messages of any kind. It works on all my office machines.

It doesn't work using either the network share or local install methods.

Any help is appreciated,
Corbin de Bruin

Need to find overlapping or intersecting polygons with in same layer - efficiently

$
0
0
I have a polygon feature classs with millions of records, I need to find list of overlapping or intesecting polygons in the same feature class, how to do it efficiently, I need a code snippet for the same. Attached image and requirement in pictorial view.



Attachment 24115
Attached Thumbnails
Click image for larger version

Name:	SpatialIntesection.png‎
Views:	N/A
Size:	20.5 KB
ID:	24114   Click image for larger version

Name:	SpatialIntesection.png‎
Views:	N/A
Size:	19.7 KB
ID:	24115  

Process IFeatureCursor results many times without re-applying query/filter

$
0
0
I have a spatial filter performing as I want it to, returning me an IFeatureCursor object that I can loop through. I want to be able to loop through the IFeatureCursor object more than once without re-applying the filter, the spatial filtering can take some time to apply in large data sets. Is there a method available for this, like 'IFeature.FirstFeature()' rather than having to re-apply the filter and start wiith 'IFeature.NextFeature()' again? Code below.

Thanks

Rob

Code:

Dictionary<int, Dictionary<int, string>> FIDs = new Dictionary<int, Dictionary<int, string>>();
while ((pFeat = pFeatCursor.NextFeature()) != null)
{
        int thisFID = (int)pFeat.Value[fidIdx];
        FIDs.Add(thisFID, new Dictionary<int, string>());


        ISpatialFilter SPF = new SpatialFilter();
        SPF.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin;
        SPF.Geometry = pFeat.ShapeCopy;


        IFeatureCursor IFC2 = resultFeatLay.Search(SPF, false);
        IFeature IF2;

        int theCount = 1;
        while ((IF2 = IFC2.NextFeature()) != null)
        {
                FIDs[thisFID].Add((int)IF2.Value[fidIdx], (string)IF2.Value[splitIdx]);
                theCount += 1;
        }

        //THIS IS MY ATTEMPT AT STARTING THE LOOP AGAIN, TO NO AVAIL
        while ((IF2 = IFC2.NextFeature()) != null)
        {
                string stophere = "";
        }

}

Conversion error : esriNauticalMiles converts to 1853 meters

$
0
0
hi everyone


Using the ArcObject/C++ it seems as if IUnitConverter converts 1 esriNauticalMiles to 1853 meters. The international NM is 1852. However the imperial NM is 1853.

Googling around it seems as if most references in ESRI context pertains to the Intl. NM, but I nevertheless get 1853.


Anyone else know anything about this ?

Cheers,
Anders

Exception RPC_E_SERVERFAULT(0x80010105) : While adding ArcGIS Map Service through TCP

$
0
0
Hi all,

I am trying to add ArcGIS Map Service into ArcDesktop.I have implemented the code on ESRI command and is working fine.
Same code is not working on below scenarios,

1. Receiving data through TCP duplex communication channel(Policy server) and on message receive event,execute the add layer code..
2. Receiving data from clipbard.

On both cases i am removing manual button click event to add data.

Processing of data starts on event raised from TCP or Clipbord in Arcmap environment(C# Arcobject).

System is throwing com exception in below step.

Code:

map.AddLayer(layer);

Error ...
ESRI.ArcGIS.Carto
Message = "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"

Any help would be appreciated,

Thanks,
Prashant

IEditLayers.IsEditable true when not editing

$
0
0
Just noticed an issue with one of my tools in Arc10 where it checks a layer to see if it is editable and getting a true result even though I'm not editing any data. This same tool worked for years in Arc9.3.1. But in Arc10 (SP5), IEditLayers.IsEditable appears to always return true when you are not editing any data. It does return false if you are editing in a workspace that doesn't include this layer. The work-around is to do two checks. a) Am I editing anything and b) is the layer editable.

I haven't checked this behavior in Arc10.1.

Use esriArcMapUI.MxSelectionMenu in ArcEngine App

$
0
0
I am creating an app for non gis users. Clerks in the Planning and Zoning Dept. Part of the requirements is to be able to select lots of parcels that define an overall polygon that will be used as a project boundary. Some of the times there are only 4 or 5 parcels and the workflow is just fine. Other times there are hundreds of parcels that need to be selected and this is where my issue lies. I've added the graphics creation tools, ie esriControls.ControlsNewPolygonTool and the select by graphics button built into ArcEngine. This works ok in theory but it is harder in practice. I've enabled arrow scrolling and a right-click pan so when they are drawing the graphic polygon they can zoom in and out and scroll around. Basically, I've created a viable option for the workflow.

What I would like to do and what I wanted to know, was how do I change the interactive selection method used by the selection tool. It seems to be stuck on Create New Selection. I would like to set it to Add to Current Selection. I tried opening the MXD that the map control uses and setting the Interactive Selection method there but the map control does not recgonize any change.

I had thought about calling the code like I would in arcmap

Code:



        Dim aMxd As IMxDocument = CType(My.ArcMap.Application.Document, IMxDocument)    'get arcmap document

        Dim mSelMenuUid As UID = New UIDClass()
        mSelMenuUid.Value = "{EB70D0AF-0FA4-11D3-9F82-00C04F6BC78E}"
        Dim pSelMenu As ICommandBar = My.ArcMap.Application.Document.CommandBars.Find(mSelMenuUid)

        Dim pSelMethodMenu As ICommandBar = pSelMenu.Item(7)
        Dim pRemoveSel As ICommandItem = pSelMethodMenu.Item(2)

        pRemoveSel.Execute()

This works just fine in ArcMap. When I try to implement the same thing in ArcEngine app I'm lost. I thought I could just put the selection menu in the ArcEngine app with

AxToolbarControl1.AddMenuItem("esriArcMapUI.MxSelectionMenu", -1, False, 1)

When I add this line, the menu shows up and when I try to click on it I get an error about protected memory. "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." I've added a reference and import to my app for the ArcMapUI.

Don't know what else to try. Really, what I want to do is to set the Interactive Selection Method for the Map Control to be "Add to Current Selection" and be done with it.

HELP! LOL

Michael

Error Compiling ArcObjects Sample

$
0
0
I installed the ArcObjects SDK .NET (10.1) on my system. When I try to build the solution for the NetSimpleRESTSOE project, I get this error:

"Could not load file or assembly 'ESRI.ArcGIS.SOESupport, Version=10.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86' or one of its dependencies. The system cannot find the file specified."

I've tried with Visual Studio 2012, Visual Web Developer 2010 Express, and Visual C# 2010 Express, but all give the same error.

Any ideas why?

Does the ArcObjects SDK .NET need to be installed on the SAME server where ArcGIS Server is installed?

Thanks...

Refer to the document/application in an add-in?

$
0
0
Is it possible to refer to the Application/document in an add-in?

I've successfully attached a dockable window to a button - now what do I do?

It doesn't seem to like:

Dim pMxDoc As IMxDocument = new MxDocument
nor can you do:

Dim pMxDoc As IMxDocument = m_application.Document
or maybe you can but how do you set m_application in a dockable window?

ANSWER: Add the lines in bold

Private m_pApp As ESRI.ArcGIS.Framework.IApplication

Public Sub New(ByVal hook As Object)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.Hook = hook
m_pApp = hook

End Sub
.....
then down in your button_click do:

Dim pMxDocument As IMxDocument = m_pApp.Document

Thanks!

Zoom to layer defined by CreateSelectionLayer

$
0
0
Greetings,

I have several layers that have been created from a non-displayed "master layer" using IFeatureLayerDefinition2.CreateSelectionLayer to cut down on the number of feature classes stored in a file GeoDatabase (gdb).

This has worked fine adding the layers to the table of contents and only displaying the desired features. However, when using the sample code to Zoom to a Layer (Displaying a TOCControl Context Menu sample), the extent sent via "ref layer" is the full extent of all features that were in the feature class up to that point. For example Layer1 of Rectangle 1 zooms to just Rectangle 1. Layer 3 created by querying for Rectangle 3 zooms to rectangles 1, 2 and 3.

How do I zoom only into the feature(s) that were part of the original query in the CreateSelectionLayer?

Thanks!

-- Glenn

AutomationException:Item Not Found in 'Esri.GeoDatabase'.

$
0
0
Hi,

Can any one help me in solving this exception with ArcObjects java.

The following is the Automation Exception I am getting when I am trying to open the feature dataset through the IFeatureWorkSpace reference.

AutomationException:Item Not Found in 'Esri.GeoDatabase'.

at IFeatureWorkSpaceproxy.openFeatureDataset(unknownsource).




This is what I am getting when trying to get the feature dataset reference. BTW, I am trying to work all this through accessing the file geodatabase.

I checked with the feature dataset name present in the file geo database through the ArcCatalog. The same name is the one I am passing to the openFeatureDataSet() method. But I am getting the above mentioned exception.

Can any one please help me in resolving this issue?

Thanks in Advance.

How to determine where an IDockableWindow is docked?

$
0
0
I know I can cast a dockablewindow to IWindowPosition and get it's State to see if it's floating (esriDockFlags.esriDockFloat) or docked (esriWindowState.esriWSNormal) but how do you determine where it's docked if it is docked?

Terry
Viewing all 1374 articles
Browse latest View live