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

Given an ISymbol, how to know if ICartographicLineSymbol or ICharacterMarker

$
0
0
Given an ISymbol, how do I know if it's a an ICartographicLineSymbol or ICharacterMarkerSymbol?

I tried using the "is" C# keyword....

if(mysymbol is ICartographicLineSymbol) {
} else if(mysymbol is ICharacterMarkerSymbol) {
}

But it doesn't work.

It does work with ISimpleFillSymbol however.

Any suggestions ?

ESRI's development plan for developers

$
0
0
I think I am going to scream. We develop in C# using Visual Studio (2010, 2012, 2013 - doesn't matter).

I am now investigating our migration to 10.2.2. I was pleased to note that no changes (other than a build) were required to make a 10.2.2 compatible program for ArcEngine and ArcGIS. All the builds worked as x86 builds.

So I turned my attention to ArcGIS Server. I spent most of the day trying to figure out why my Extensions weren't working even though they compiled and loaded fine. Finally I compiled the base projects with "Any CPU". Like magic everything started working.

So (hopefully) I took my "Any CPU" compiled projects and put them back into ArcEngine and ArcGIS. No luck - you STILL have to compile as x86. So now it seems I have to maintain ANOTHER set of DLL's just for ArcGIS Server.

It shouldn't surprise me. ESRI has never been one to care much for code reuse. (Witness Silverlight API, WPF API, etc which are all different code bases from ArcObjects - not to mention the old MapObjects).

My suggestion to ESRI. Make it ALL work same - just one set of Objects for everything compiled the same way, please. It will save me many headaches and phone calls to support.

CPP vs VCPP API

$
0
0
Hi I am trying to understand the difference between the C++ cross platform API and the desktop Visual C++ API. I was looking at the TinToPoint sample that is in both the VC++ API sample and the C++ cross platform API. I understand how the include directories are set up from the cross platform API, I don't understand how it is setup for the VC++. I understand the binding to the production (with ArcGISVersion.dll) is done in VC++ because it is similar to binding in C# or VB.net, but that whole thing is not done in the cross platform but it still works on my workstation...

I have other code that is structured like the cross platform where the license fails to initialize completely. It doesn't do the binding (ESRI_SET_VERSION) but I am not sure if I need that or not... Maybe someone can clarify why the two APIs are different (although I am using VS 2010 in both cases.)

does IMarkerSymbol extend ISymbol ?

$
0
0
Because the reference does not say that it does.

Usually the reference would have an "Inherited Interfaces" section, but IMarkerSymbol, ILineSymbol, and IFillSymbol don't have it.

Identify Route Location GUID different in .NET?

$
0
0
Finally getting around to porting a VBA based toolset to an addin using .NET. On a dialog, I include a button for my users to quickly change their active tool to ESRI's Route Identify tool. Under VBA, this was referenced as arcid.Lr_Route_Identify and the UID was/is "{6C3CC7D2-0EA4-43A0-88C3-911FEDCBF268}".

I'm trying to do the same thing on the .NET side but that UID isn't listed in the documentation. The tool still exists so I'm not sure what to do here.

My little .NET code is like this:
Code:

    Private Sub cmdRteIdentify_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdRteIdentify.Click
        Try
            'Changes the current tool to the Route Identify Tool
            Dim application = My.ArcMap.Application
            Dim pUID As New UID

            pUID.Value = "esriArcMapUI.SelectTool"
            application.CurrentTool = application.Document.CommandBars.Find(pUID)
        Catch ex As Exception
            globalErrorHandler(ex)
        End Try
    End Sub

Should I just use the "{...}" value in my routine and just ignore the fact that I can't find the appropriate "esriArcMapUI.x" equivalent? I like using the latter since it's a bit more reader friendly for understanding the code later on down the line.

Thanks!
Steve

Geographic Coordinate System Corruption in ArcObjects 10.2.2

$
0
0
Hi,

We just upgrade from ArcObjects 10.1 to 10.2.2 and now we're having a problem where the Geographic Coordinate System (GCS) object gets corrupted after calling the DefineEx (or Define) method a few times (see code sample 1).

I found a workaround by pulling the GCS object from a projection coordinate system object (see code sample 2).

Is there any reason for this behavior and how can I create a Geographic Coordinate System from a factory code?

Thanks,
Niro

Code Sample 1
Code:


                int numberOfErrors = 0;

                for (int i = 0; i < 1000; i++)
                {
                    var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); //(ISpatialReferenceFactory4)Activator.CreateInstance(Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"));
                    var geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983) as IGeographicCoordinateSystem;
//                    var projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N);
//                    var geographicCoordinateSystem = projectedCoordinateSystem.GeographicCoordinateSystem;
                     
                    (geographicCoordinateSystem as IGeographicCoordinateSystemEdit).DefineEx(
                        geographicCoordinateSystem.Name,
                        geographicCoordinateSystem.Alias,
                        geographicCoordinateSystem.Abbreviation,
                        geographicCoordinateSystem.Remarks,
                        geographicCoordinateSystem.Usage,
                        geographicCoordinateSystem.Datum,
                        geographicCoordinateSystem.PrimeMeridian,
                        geographicCoordinateSystem.CoordinateUnit);

                    if (String.IsNullOrEmpty(geographicCoordinateSystem.Name))
                        numberOfErrors++;
                }

Code Sample 2
Code:

   
                int numberOfErrors = 0;

                for (int i = 0; i < 1000; i++)
                {
                    var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); //(ISpatialReferenceFactory4)Activator.CreateInstance(Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"));
//                    var geographicCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983) as IGeographicCoordinateSystem;
                    var projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_17N);
                    var geographicCoordinateSystem = projectedCoordinateSystem.GeographicCoordinateSystem;
                     
                    (geographicCoordinateSystem as IGeographicCoordinateSystemEdit).DefineEx(
                        geographicCoordinateSystem.Name,
                        geographicCoordinateSystem.Alias,
                        geographicCoordinateSystem.Abbreviation,
                        geographicCoordinateSystem.Remarks,
                        geographicCoordinateSystem.Usage,
                        geographicCoordinateSystem.Datum,
                        geographicCoordinateSystem.PrimeMeridian,
                        geographicCoordinateSystem.CoordinateUnit);

                    if (String.IsNullOrEmpty(geographicCoordinateSystem.Name))
                        numberOfErrors++;

Using IGeoProcessor2 to update Oracle Spatial

$
0
0
In the below example the input and out are shape files read from folders.Is it possible to read and write Oracle Spatial Geometry tables? I have ArcGIS,ArcSDE and Oracle Spatial 11g.
How to set parameters to create a new Geometry table if it does not exist?
How to append the data if a geometry table already exists ?

Code:

IGeoProcessor2 pGeoProcessor = new GeoProcessorClass();
IVariantArray parameters = new VarArrayClass();
parameters.Add(pFlayer);
parameters.Add(OutLayerPath + "\\" + pFlayer.Name + "MBM.shp");
parameters.Add("CIRCLE");
parameters.Add("NONE");
parameters.Add("");
parameters.Add("MBG_FIELDS");
pGeoProcessor.Execute("MinimumBoundingGeometry_management", parameters, null);

Can't find the way to fill in_raster parameter

$
0
0
Dear All,

I am trying to work with ESRI.ArcGIS.SpatialAnalystTools.CellStatistics, and the input is a set of layers, i couldn't find any way to pass this parameter, I am using c#, I tried Array of objects, List<ILayer>, ILayer<object> and IArray, and all of them failed, can you please help in this issue?

Thank you
Jalal

IWindowPosition.Move does not work.

$
0
0
Hello,

Below is my code to move the Toolbar in the ArcMap.

Code:

private void DockToolbar(string guidValue)
        {
            try
            {
                ICommandBars pCommandBars;
                ICommandBar pCommandBar;
             
                pCommandBars = pApps.Document.CommandBars;

                UID pUID = new UID();
                pUID.Value = guidValue;

                pCommandBar = (ICommandBar)pCommandBars.Find(pUID);

                if (pCommandBar != null)
                {
                    IWindowPosition windowPos = (IWindowPosition)pCommandBar;
                    pCommandBar.Dock(esriDockFlags.esriDockShow);
                    windowPos.Move(1000, 1000);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }

After running the code, IWindowPosition.Move does not have any effect on the Toolbar. I found here that this was a bug back in version 10.0. So, I would like to know if this bug has been fixed or not or is there any way to move the Toolbar to the desired location.

Basically, we are adding few toolbars to the ArcMap through the custom extension. And when these toolbars are added, either they are floating, on top of of each other or docked that shrinks the ArcMap map area. So, it would be great is know if there is any way to add the toolbars in an organized way.

OS : Windows 7 x64
ArcGIS version 10.2.1.

Any help is appreciated.

Thanks,
S.

Need some example for UseGeodesicBuffering

$
0
0
I’m trying to find a geodesic buffered region for a given polyline in a WGS_1984_UTM_Zone_52N coordinate system. However, When I try to get a buffered polygon for this, the program shows AccessViolationException for “Attempted to read or write protected memory. This is often an indication that other memory is corrupt”. Below is what I tried:

Quote:

public void DrawBuffer()
{
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = axMapControl1.ActiveView.ScreenDisplay;
IElement pInptLine = new LineElementClass();

object missing = Type.Missing;
IFillShapeElement pElem = new CircleElementClass();
ISimpleFillSymbol sysm = new SimpleFillSymbol();

sysm.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
sysm.Outline.Width = 20;

//Get the IRGBColor interface
IRgbColor color = new RgbColorClass();
//Set the color properties
color.Red = 255; color.Green = 0; color.Blue = 0;
color.Transparency = 255;

sysm.Color = color; sysm.Outline.Color = color;
pElem.Symbol = sysm;

ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
simpleLineSymbol.Color = color;

ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
ESRI.ArcGIS.Display.IRubberBand2 rubberBand = new ESRI.ArcGIS.Display.RubberLineClass();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);

screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolyline(geometry);
screenDisplay.FinishDrawing();

//Start Buffering
IConstructMultipoint myMultiPoint = new MultipointClass();
myMultiPoint.ConstructDivideLength(geometry as ICurve, 10000);
IGeometryCollection geometryBag = new GeometryBagClass();
IGeometryCollection Rslt = new GeometryBagClass();
IPointCollection pointCollection = myMultiPoint as IPointCollection;


object Missing = Type.Missing;

for(int i = 0; i<pointCollection.PointCount ; i++ )
{
geometryBag.AddGeometry(pointCollection.get_Point(i), ref Missing, ref Missing);
}
IGeometryBag enumGeometry = geometryBag as IGeometryBag;
IBufferConstruction ipBufCon = new BufferConstruction();
IBufferConstructionProperties2 ipBufConProp = (IBufferConstructionProperties2)ipBufCon;
ipBufConProp.UseGeodesicBuffering = true;
ipBufConProp.UnionOverlappingBuffers = true;
ipBufCon.ConstructBuffers((IEnumGeometry)enumGeometry, 500.0 * 1000.0, Rslt);

IPolygon bufrPolygon = Rslt.get_Geometry(0) as IPolygon;

//Fill the BufrPolygon
IElement iElem = pElem as IElement;
iElem.Geometry = bufrPolygon as IGeometry;

IFillShapeElement pElemFillShp = pElem as IFillShapeElement;
//Add the result as an element of the map
pElemFillShp.Symbol = sysm;
axMapControl1.ActiveView.GraphicsContainer.AddElement(pElemFillShp as IElement, 0);
}
Whenever I turned off the UseGeodesicBuffering, the program works fine. But when the property is true, the crash occurs. I’m trying to find out the problem & debug the code, and still need some help. Any ideas why this code crashes or some working code example with UseGeodesicBuffering = true would be most grateful. Thank you in advance.

The Workspace is not connected .......Error ArcGis 10.2.1

$
0
0
Dear Friends
We have recently migrated from ArcGis 9.1 to 10.2.1 VS2010 .We have tool to insert features into a feature class.Initialy after migration tool worked without any errors but sometimes tool throws "The Workspace is not connected" ErrorCode -2147467259.After debugging i found out pEditor.StartOperation() line is not executing and throws error.Kindly help me for this issue



Public Function startEditing(ByVal pEditor As IEditor, ByVal pWorkspace As IWorkspace) As Boolean
Try

If pEditor.EditState = esriEditState.esriStateNotEditing Then
pEditor.StartEditing(pWorkspace)
End If

pEditor.StartOperation()
Return True
Catch ex As Exception
MsgBox(ex.Message & "-startEditing", MsgBoxStyle.Information, "Start Editing")
Return False
End Try

End Function


Thanks in advance
Kroy

Creating *actual* custom commands with BaseToolbar

$
0
0
Hello,

I am in the process of creating a toolbar containing nested menus with buttons and other menus for access of some custom functionality for end users.

For whatever reason, since the ArcMap addin templates do not seem to allow a toolbar contained menus with nested submenus, I turned to the non-addin approach of creating a BaseToolbar which has the ability to add commands (menus, buttons, etc.):

Code:

public MyToolbar()
{
    this.AddItem(typeof(ButtonItem));
}

where ButtonItem is a class which inherits BaseCommand:

Code:

[Guid("2b3041ff-482c-4c36-aef3-2bf79546fb82")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("TestLib.ButtonItem")]
public class ButtonItem : BaseCommand
{
    // ...
}

What I really want these buttons to do is have some non-ESRI functionality (which none of the examples provide), for example, when clicked, retrieves some id, name, or caption of this button, and traverses a directory on the file system to add a new layer to the map, or create a config .xml file somewhere on the file system.

However, there seems to be no room to add any custom methods or properties to ButtonItem, since the method AddItem() of the base toolbar does not take an instantiated object, but either a progid, or class type.

How can I handle the onClick method of this specific button to access class properties? There does not seem to be a clear indication of how/when the constructor and onCreate methods are executed.

Does anyone have experience utilizing this toolbar/menu style, or know how to dynamically add nested menu items to an add-in toolbar (loop over a directory, and add a menu item for a folder, or a button item for a file)?

Get points along a polyline at defined distance

$
0
0
Hello,

i need to store into my array the points along the polyline each defined distance.
Example:
The Polyline lenght is 50m, i set interval to 5m. I have to store in the array all the points along the polyline each 5meter.(points on 0m-5m-10m-15m....).

I'm using c#.
Any function to get theese points?

Thanks,
Andrea

Visual Studio 2012 Installation of ArcMap Class Library

$
0
0
Just wondering if there's any good documentation that outlines the method to build an installation project of an ArcMap Class Library using the following: Visual Studio 2012, InstallShield LE and esriregasm? I'm not totally clear on the steps to make sure the .ecfg files are placed in the clients <CommonFiles>\ArcGIS\Desktop10.2\Configuration\CATID, and the esriregasm tool is run on them?

Authorize License by code

$
0
0
Hello,

I have a question, I need authorize ArcGIS Desktop and ArcGIS Server, version 10.2, but by code. This is my code:


IAuthorizeLicense aoAuthorizeLicenseClass = new AoAuthorizeLicenseClass();

string path = @"C:\License\Desktop_Basic_268138.eslf";

aoAuthorizeLicenseClass.AuthorizeASRFromFile(path, this.asrItem.Password);

string featuresAdded = aoAuthorizeLicenseClass.FeaturesAdded;



No error and exception is threw. So, the license should be applied, but, when I start ArcMap, for example, it it not licensed.

I also use the command line to use the SoftwareAuthorization.exe, this command:

>SoftwareAuthorization.exe /LIF "C:\License\Desktop_Basic_268138.eslf" /s

But nothing happen, no error is displayed. Also, I don't know how to pass the password like the wizard ask for it if I used this software.

Please, let me know any idea or suggestion to implement, or what I'm doing wrong.

Thanks in advance for your help.

Break circle where user clicks

$
0
0
Hi, I'm having some issues right now with breaking a circle where a user clicks. The way I'm currently doing it (which works for straight polylines) is to take the Feature object and cast it to IFeatureEdit2. Afterwards I use the .SplitWithUpdate(IPoint userPoint) method on the FeatureEdit2 object.

However when I try this with a Circle feature (clicking on point 1) it creates two breaks and makes two arcs as in the image attached. I would like it to just keep one arc with a break at the point the user clicked and no where else. This way I could click on point2 later and have two arcs split by the two polylines crossing them and select/delete whatever one I no longer need.

When I click for the second time to break the line again it works as expected, however I'm left with 3 arcs instead of the 2 I want.
Attached Thumbnails
Click image for larger version

Name:	Example.png‎
Views:	N/A
Size:	8.1 KB
ID:	34456  

Join two feature class tables using STIntersects problems..... what am I missing?

$
0
0
Hello - We are using ArcGIS10 and I am using ArcObjects for Java to do some tasks (we have SDE sitting on top of Oracle). I have two tables which each have a Polygon feature. All I want to be able to do is return data from Table1 when the Table1.SHAPE intersects with the Table2.Shape and Table2.name like 'A%'. There is no equivalent of Table2.name in Table1 which is why I need to do this join. I have found two different ways to do the "intersect" statement in the WHERE clause:

1) select count(*) from Table1 t1, table2 t2 where t1.Shape.STIntersects(t2.Shape) = 1 and t2.name like 'A%';
- This gives me an ORA-00904: "T1"."SHAPE"."STINTERSECTS": invalid identifier error.

2) select count(*) from Table1 t1, table2 t2 where sde.st_intersects(t1.Shape, t2.Shape) =1 and t2.name like 'A%';
- This gives me the error:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-28595: Extproc agent : Invalid DLL Path
ORA-06512: at "SDE.ST_GEOMETRY_SHAPELIB_PKG", line 788
......

I ran both of these statements in my SQL Developer where I have full access to the tables listed as well as in my java application that uses ArcObjects, again with full access to those tables. I don't have any problems doing other queries on these tables when only one is used in the query.

I didn't think that this was going to be that difficult, but ....

Any clues about what I am missing?


Thanks - Peter

Manipulate Menu

$
0
0
How to add[using vb.net] a new menuitem to an existing [customized]menu on mainmenu bar?

Adding geometries to a GeometryBag is giving me odd results

$
0
0
I am using Java ArcObjects and I want to go through a FeatureCursor, get each feature's shape, and add the shape to a GeometryBag. What I do is the following:

Code:

GeometryBag gbag = new GeometryBag();
IGeometryCollection gcoll = (IGeometryCollection) gbag;

IFeature feat = featureCursor.nextFeature();
while (feat != null) {
    IGeometry geom = feat.getShape();
    gcoll.addGeometry(geom, null, null);
    feat = featureCursor.nextFeature();
}

The syntax that I used is based on various posts I found on how to do it. My problem is that if I go through my collection after adding all of the geometries, and print out the coordinates from the geometry envelope, all of them are the same. For example, if my feature cursor has three items, my collection will have three items, but all three items will have the same set of coordinates. I ran some debug where I checked each geom in the loop and also printed the collection information after each addGeometry call. I could see that I was getting different geometries in the loop but each time I printed the lastest for the collection, it would have the same coordinates for each item, which would be the coordinates for the last item added to the collection. I ultimately use the gbag as the geometry for a spatial query and it is returning the number of hits that are correct for items that fit within that one coordinate set so it isn't something for how I am printing out the collection items. This seemed to be an easy task but now this collection is getting whacky on me. I have tried numerous variation changes but to no avail.

Any thoughts on why the collection is not keeping the different geometry info that was added to it. It has to be something with overwriting or who knows.

Thanks for any thoughts - Peter

Releasing locks on raster objects

$
0
0
Hello,

I have written a pretty simple add-in (in C# .NET) that does some symbolizing on raster (TIF) layers, changing their renderers in the process. When I remove these raster layers from ArcMap, sometimes I need to rename them in Windows, but I cannot because a message appears telling me they are still open in ArcMap. This does not happen if I do not use the add-in on the files.

I have tried using ReleaseComObject on the raster layers before exiting the add-in, but this does not do the trick. I should point out that when the raster layers are first added to ArcMap, tif.ovr and .tif.aux.xml files are created. Could the problem have something to do with those?

Thanks,
Evan
Viewing all 1374 articles
Browse latest View live