New answers tagged arcobjects
1
The first thing you should do is put Try..Catch blocks in your code. This will make it much easier to figure out why the code is crashing. Here is an example
Private Sub FindSmallestPolygon()
'This requires the feature class to be in a geodatabase
'or has the field "Shape_Area" already calculated with the area
Dim pLayer As ...
1
Check out this page is shows you the types of cursors ArcObjects uses and gives examples in VB .net
0
I faced the same problem recently with WPF dockable window.
Resolved this by using custom ArcMap extension code from an Esri's Selection Sample add-in.
3
See the Working with the page layout section in the documentation - mainly the Map surrounds topic, which provides an overview how the most common map surrounds (legend, scalebar etc.) are structured, followed by Working with map surrounds, which shows how to add these elements to the page layout.
0
I've never tried it, but you should be able to create a REST service using the WCF REST template, then use the StaTaskScheduler as described in this answer.
However, you would not be able to manage the service using ArcGIS Server Manager. Instead, you would need to use IIS.
Also, as Khattab suggests, you could implement a custom IGpTool and deploy as a GP ...
2
You need to wrap individual paths into the higher-level geometries, which is a Polyline. Then you can check for intersection with another geometry.
The most reliable way to wrap a path in a polyline is to:
Create a new instance of Polyline
Cast the original Path as ISegmentCollection
Cast the new Polyline as ISegmentCollection
Add the path's segments to ...
0
Found Idea from
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//003n0000007w000000
“These .lock files are removed whenever you run the geoprocessing Compact tool”
string[] lockfiles = Directory.GetFiles(project.Path, "*.lock", SearchOption.AllDirectories);
if(lockfiles.Length > 0)
{
int lockCt = 0;
while (lockCt < lockfiles.Length)
...
0
I'm not sure that it works fine in C#, however, Point is 1 dimension geometry which doesn't contain valid extent. So, I recommended to use Point geometry instead of using Envelope geometry. Here is the sample code, and also I fixed some part of code which was verbose.
//Create Point
IPointPtr ipPoint(CLSID_Point);
ipPoint->PutCoords( dX, xY);
//Open ...
1
Not strictly programming, but ArcToolbox follows a more functional design paradigm.
Most tools are designed to accept a set of inputs, run a function, and return the outputs without the influence of external state.
Most tools do not edit existing layers, but create new ones (immutability).
Many tools are similar in operation to a map function. They ...
2
The single biggest reason why functional programming has come back into vogue lately is concurrency. Being able to do processing in parallel for performance reasons is becoming massively important in computing overall and GIS is no exception. Functional programming has some serious benefits in the context of creating parallel systems because of how much it ...
0
I finally got back to this project and ended up storing the map index rather than the map itself. Works great. Thanks for the help.
1
This error is caused by byte size of value, not ArcGIS version. VB6 long type is 4 byte (32 bit Integer), and .NET long type is 8 byte (64 bit Integer). However, I'm not sure why Stream class cannot use it. But in any case, .NET int type is same as VB6 long type, so you may use int type instead.
1
This one works for me. It is tested for file geodatabase, personal geodatabase.
//enumGxObject = output of IGxDialogue
IWorkspace GetWorkspace(IEnumGxObject enumGxObject)
{
IGxObject gxObject;
while ((gxObject = enumGxObject.Next()) != null)
{
Catalog.IGxDatabase2 gxDatabase;
if ((gxDatabase = gxObject as IGxDatabase2) != null)
...
1
It is possible. First, you need to register output directory or parent directory as "Data store". Because, ArcGIS Server 10.1 can only access to "Data store" directory. Next, add the output directory as IIS Virtual directory. Then, you can create file to output directory and access it from IIS.
To get more information about Data store, please follow,
...
1
Check IField.IsNullable before attempting to set a null value.
If you expected the field to be nullable, but IsNullable is false, then the field was defined incorrectly. If you are creating the field programmatically, then set IFieldEdit2.IsNullable to true. If you add it through the ArcMap UI, then make sure the Allow NULL values flag is set to Yes.
1
Try this (WILL ONLY WORK WHEN IGXOBJECT IS A SHAPEFILE):
ESRI.ArcGIS.Catalog.IGxDataset gxDataset; //Declare IgxDataset
gxDataset = (IGxDataset)gxObj; //cast IgxObject to IgxDataset
ESRI.ArcGIS.Geodatabase.IDataset gDataset;//Declare IDataset
gDataset = gxDataset.Dataset; //IGxDataset to ...
1
This code works for geodatabases, but I haven't figured out how to get a workspace for a shapefile using this method
Private Sub GetWorkspace()
Dim pEnumGxObj As ESRI.ArcGIS.Catalog.IEnumGxObject
Dim pFCFilter As New ESRI.ArcGIS.Catalog.GxFilterWorkspaces
Dim pGxDatabase As ESRI.ArcGIS.Catalog.IGxDatabase2
Dim pGxDialog As New ...
0
This snippet is a bit old and in VBA, however I think it should give you the result you are looking for (after converting it to .NET/C# add-in). It basically uses a buffered search point on mouse down event, then uses a spatial filter and search cursor to return the feature.
Find a Feature Programmatically
0
i did as u asked me however the return cursor contains all the record rather than a single record. Please look at the code below 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;
...
2
As far as I know, there is no way to edit the complete forms themselves that ESRI provides, you can only access them and use them.
A solution for your problem involves two parts:
1) A form that that accesses the functionality of the IIdentifyDialog interface and has the customization you desire. You could make it very similar to the ESRI form by plugging ...
1
The reason is, because mouse wheel event is enabled for only activated window (focused window). So, when you press the tool, then MapControl lost focus and the tool command (window) will get focus. Here the sample how to set focus on MapControl when you activate the custom tool.
[DllImport("user32.dll")]
static extern IntPtr SetFocus(IntPtr hWnd);
/// ...
0
I think you should check can you copy this dataset or not. Try this:
pDs = pFeatureClass.FeatureDataset;
if(pDs.CanCopy )
pDs.Copy(strOutVoronoiFile, (IWorkspace)pFinalFWS);
For details about CanCopy property, follow this.
1
Although I have found no documentation to the effect that a Projected Coordinate System is required it is perhaps unsurprising that a Geographic Coordinate System is unsupported because the length of a degree varies depending on the latitude.
I suspect that a documentation enhancement is the most that is likely to happen with this but I encourage you to ...
1
INetworkTurn is a noncreatable object. You can only get it from querying an existing turn element. So if the turn you are trying to query does not yet exist, you will have to first create it.
Once you do have a turn, you will need to use INetworkQuery.QueryTurn and pass in the turn element ID as an argument.
...
1
As you have discovered the order of polylines is dictated by the row order returned in the cursor so you will have to do some post processing. This is how I would do it:
For each polyline identify which end is intersecting road A (i.e. from or to end)
Cast polyline into IPointcollection and depending on the orientation get the next vertex along its length.
...
0
If I were doing it I would get the XY coordinate of the point clicked using a tool button. Convert these coordinates into a point geometry and feed that into an ISpatialFilter then create a cursor over the FeatureLayer where the point intersects. I've made various assumptions in that statement...
This question is better answered by the ESRI forum as what ...
1
I had a similar problem with a custom tool. I have a custom form which gets opened by a button on an AddIn-Toolbar in ArcGis 10.x. On this form there is a button that should retreive the coordinates of a click in the map, snapping included.
I could start the tool and handle the click in the map, but I could not get the value back to my form, because the cast ...
0
concerning the Pan using the click on mouse wheel
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
if (e.button == 4)
{
//MapControl map = (MapControl)((ToolbarControl)hookHelper.getHook()).getBuddy();
display = axMapControl1.ActiveView.ScreenDisplay;
...
2
I think you just need to refresh the Table of Contents. Try something like this:
IMxDocument pDoc = (IMxDocument)pApp.Document;
for (int i = 0; i < pDoc.ContentsViewCount; i++)
{
pDoc.ContentsView[i].Refresh(null);
}
0
I don't know why do you need to add the tool in a toolbar. Because, I have worked with some similar thing and I haven't find any need to add it in the tool bar.
In my case, when user clicks on a button in the dockable window, a tool activates. To perform this work, my tool class looks like following:
My tool id is:"ArcMap_SelectionTool"
My tool class name ...
0
First of all, SOE(Server Object Extension) can be used only for MapService. So, the best way is implement your custom NASolver as custom GP Tool and publish it to GP Service. Then you could run NASolver by GP Service. Please read the following site "Do you need an SOE?" section.
"What is a server object extension?"
...
1
The answer of lbross helped me a lot. Later I found almost the same solution in the ArcGis snippet finder: 'Statements - Use a Tool in a Windows Form.snippet' (I am using C#)
I can't vote the answer up because I have too less reputation.
0
Here is a function I use:
public static IPolyline6 PolygonToPolyline(IPolygon4 inPolygon) {
ISegmentCollection outPolyline = new PolylineClass() as ISegmentCollection;
try {
outPolyline.AddSegmentCollection(inPolygon as ISegmentCollection);
// Mirror spatial reference of input
IPolyline6 ...
0
You can use ESRI.ArcGIS.Geodatabase.IJSONConverterGdb
The operation handler in your SOE would have something like this:
JsonObject jsonObj;
bool found = operationInput.TryGetJsonObject("RecordSet", out jsonObj);
if (!found)
throw new ArgumentNullException("RecordSet");
string recordSetJsonString = ...
1
I found two solutions for my question. The first one is to override the ProcessCmdKey method in my DockableWindow class e.g:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
if (keyData == (Keys.Alt | Keys.A)) {
button1.PerformClick();
return true;
}
if (keyData == (Keys.Alt | Keys.B)) {
...
1
In your code, you are calling AddTemplates method before calling SetDefaultValue method. I guess this cause the strange result. If calling them at reverse, then I confirmed that it works correctly.
'pLayer' is FeatureLayer Object as IGeoFeatureLayer
'pEditor is Editor Object as IEditor3
Dim pRender As IUniqueValueRenderer = TryCast(pLayer.Renderer, ...
0
As far as I know, there are two GeoTransformationOperationSet objects and you should remove both of it. The sample code is,
//Remove from Map Object
IMapGeographicTransformations pMapGeoTrans = pMap as IMapGeographicTransformations;
IGeoTransformationOperationSet pGeoTransSet = pMapGeoTrans.GeographicTransformations;
pGeoTransSet.RemoveAll();
//Remove ...
1
If your Methods is capsulated to ArcMap Command, you could use AcceleratorTable.
IAcceleratorTable pAccTable = m_app.Document.Accelerators;
UID uid = new UIDClass();
//Some command uid
uid.Value = "{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}";
bool addedAcc = pAccTable.Add(uid, System.Convert.ToInt32(System.Windows.Forms.Keys.A), true, false, false) ;
But, if ...
0
I tried a workaround to my casting problem: I first cast my IFeatureClass object into a FeatureClass object, then I cast this FeatureClass into an ISchemaLock.
IFeatureClass --cast--> FeatureClass --cast--> ISchemaLock
The code looks like this:
// Attemp to convert an IFeatureClass into an ISchemaLock
// and then change the SchemaLock
IFeatureClass fc = ...
0
Your onSelection combo box event needs to fire off this property:
IFeatureLayerDefinition.DefinitionExpression Property
to only show those features within the layer.
Here is a code snippet you can reference:
http://edndoc.esri.com/arcobjects/8.3/componenthelp/esricore/IFeatureLayerDefinition_Example.htm
0
This type of call works for me in a number of C# applications, but afraid I don't have a Java environment to work with. From the error, it sounds like the object you have may not support casting in this way. The following article maybe helpful Casting and Runtime type checking. If that is the case, you can try something like
IFeatureClass fc = ...
1
the solution is :
the new Model is like :
it Paramters like :
the Code :
Sub diso()
Dim gp As GeoProcessor = New ESRI.ArcGIS.Geoprocessing.GeoProcessor()
Dim trac As ITrackCancel = New CancelTracker
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Dim parameters As IVariantArray = New ...
2
ArcMap has a default selection tolerance of 3 pixels. The IMxDocument interface exposes this value in two ways:
SearchTolerance: The global search tolerance in geographic units for selection. The application's search tolerance is measured and set using pixel units. This property automatically converts the size of the pixels to map units.
...
2
First, to set UniqueValueRenderer in programmably, "Value Field" is set as,
pUniqueValueRenderer.FieldCount = 1;
pUniqueValueRenderer.set_Field(0, fieldName);
Next, RandomColorRamp does not guarantee unique colors. So you need to implement color creation part by your own self. One approach, create existed color list and check if the color is already used. ...
1
You should follow three process.
1. Create RootMenu with implement BaseMenu and IRootLevelMenu. This class must been visible by Framework, So it need's to register to MxCommands Component Category.
2. Create NestedMenu with implement BaseMenu. And added by RootMenu. This class doesn't need to register to Component Category.
3. Create MultiItem with implement ...
3
I had exactly the same problem. To create the .ecfg files on a build machine without admin privileges and without changing the Local Machine hive of the registry we built a small utility:
https://github.com/manimahler/HarvestArcGISComponentCategories
Once we created the files I (actually msbuild) add the .ecfg files to the installer (rather than creating a ...
1
Use your ArcObjects code to call on the built-in tools Combine and Pivot Table. You can combine two different rasters having the same classes that you wish to compare as shown here, and before pivoting, add two new text fields to calculate strings for the class values that correspond to InRas1 and InRas2.
Top 50 recent answers are included




