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

How to change feature weights for standard graphics layer programmatically??

$
0
0
Hey all,

I wrote some ArcObjects code (ArcGIS 9.2, VB.NET) which creates some graphic elements programmatically and then exports the map. some labels that overlap with the graphic features are not displayed. the "manual" solution is to open the Labeling toolbar, click on "Label Weight Ranking" and set the feature weight of the standard layer to "none". I would like to change the feature weights programmatically.
Does anybody know which interfaces I can use in order to access the feature weights of the standard layer??

Thank you in advance for you help!

Regards,
Johannes

Duplicate the Info Button Functionality

$
0
0
I'm looking to duplicate the Info toolbar button (from ArcMap) functionality in a .NET application that is using AxMapControl. I would like a user to be able to left-click on the map and that causes a dialog to pop up displaying information for the layers about the point that was clicked on.

I have already tried using the point to create a IGeometry and using the IGeometry with a ISpatialFilter that gets passed into the IFeatureClass.Search() method on each of the layers that are part of the map. Even after clicking directly on an address point that I know to be part of a selectable layer, nothing is returned from my search call.

Any help or pointers will be appreciated.

Error: "The name Arcmap does not exist in the current context"

$
0
0
I bought a book called "Beggining Argis for Desktop Development Using .NET". In chapter 2 there is an exercise to create and add-in.
So I created an add in in Visual Studio 2010 but the class file has an error. It says "The name Arcmap does not exist in the current context". I even tried to add using ESRI.ArCGIS.* to no avail. Does anybody know why I am getting this error ? I am using Arcmap 10.1. Thank you for any help

Code:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.ArcMapUI;


namespace ArcMapAddin1
{
    public class ShowTime : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        public ShowTime()
        {
        }

        protected override void OnClick()
        {

            Arcmap.Application.Caption = DateTime.Now.ToLongTimeString();
        }
        protected override void OnUpdate()
        {
            Enabled = ArcMap.Application != null;
        }
    }

ArcGlobe Draw Rectangle OpenGL

$
0
0
I've only successfully drawn a rectangle by having a custom globe layer rasterized, therefore using the 2D display basically to draw using the 2D symbols.

Inside of my DrawImmediate function, I have been able to draw a rectangle with GeographicToGeocentric to convert Lat/Lon coordinates to Geocentric but the Quad draws through the globe and is not 'draped' on it.

So I figured I could do in my DrawImmediate call:

myGlobeDisplay.DirectOpenGLDraw = true;

myGlobeDisplay.SetSymbol(new TextureFillSymbolClass() { Color = YELLOW_COLOR });
myGlobeDisplay.DrawRectangle(new EnvelopeClass() { XMin = 0, XMax = 40, YMin = 0, YMax = 40 });

myGlobeDisplay.DirectOpenGLDraw = false;

But this seems to have no effect. I see plenty of examples for markers but not for rectangles, polygons, etc.

How to realize tool of the Arctoolbox with VBA?

$
0
0
Help me realize Arctoolbox's tool Split Line At Vertices (Data Management) with VBA.
How can I do this in VBA?

Add ArcGIS Reference - Why is Server Disabled?

$
0
0
I'm working on a Windows 7 PC with ArcGIS 10.1, ArcGIS for Server 10.1, the ArcObjects SDK, and Visual Studio 2010 installed. Everything is licensed.

I am currently working on a WCF REST service that uses ArcObjects. When I open the AddArcGIS Reference dialog, the Server section is disabled. I don't know if there is anything I need in there, but I would like to add any assemblies it may contain so that I can look though them in the Object Browser.

Attachment 26081

I've seen some screenshots in the help that show it active. Under what circumstances is it active?
Attached Thumbnails
Click image for larger version

Name:	2013-07-19 17.29.20.png‎
Views:	N/A
Size:	25.2 KB
ID:	26081  

Objects in this class cannot be updated outside an edit session

$
0
0
HI,

I am trying to delete selected features of a feature class . FOllowing is what i am trying to edit a PGDB --

Code:

        private void openFromFile_pGDB_Workspace(String inPGDB)throws Exception{
                IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactory();
                IWorkspace workspace = new Workspace(workspaceFactory.openFromFile(inPGDB, 0));
                IFeatureWorkspace ifw = (IFeatureWorkspace) workspace;
                IFeatureClass ifetclass =  ifw.openFeatureClass("CPAnode");
                IWorkspaceEdit iwe = (IWorkspaceEdit)workspace;
                iwe.startEditing(true);
                iwe.startEditOperation();
                  IFeatureCursor ifc = ifetclass.search(null, true);
                  int field = ifc.findField("CONSTRUCTIONSTATUS");
                  System.out.println("CONSTRUCTIONSTATUS :"+field);
                  IFeature iff = ifc.nextFeature();
                  while((iff = ifc.nextFeature()) != null)
                  {
                         
                      iff.setValue(field, null);
                      iff.store();
                     
                  }
                iwe.stopEditOperation();
                iwe.stopEditing(true);
         
           
          }

This if what i am getting in console ---

CONSTRUCTIONSTATUS :5
AutomationException: 0x80041354 - Objects in this class cannot be updated outside an edit session [CPAnode] in 'ESRI GeoDatabase'
at com.esri.arcgis.geodatabase.SimpleJunctionFeature.store(Unknown Source)
at avineon.Delete.openFromFile_pGDB_Workspace(Delete.java:137)
at avineon.Delete.main(Delete.java:85)
Error: AutomationException: Objects in this class cannot be updated outside an edit session [CPAnode]
Sample failed. Exiting...


I am getting a hard time to edit these feature , if this is not the correct way to edit features than what else should i try.

Execute geoprocessor problem to create a fishnet

$
0
0
Hello everybody,

I'm sorry, I just begin to program with ArcObjects in VB.Net (ArcGIS 10) and maybe this question have been already asked.
I try to create a fishnet by code but I have a problem. The user gives the cell size and the layer in enter. With these data, I define the envelope, top, bottom, left, right, number of rows and number of columns, etc.
Nevertheless, I have a error message : "Une erreur HRESULT E_FAIL a été retournée à partir d'un appel à un composant COM."

Can you help ? Have you an idea to solve the problem ? This is probably an error in code but I don't see where...

Thanks in advance for your responses.

Best regards,
Rory

Code:


Public Shared Sub CreateFishnet(ByVal pMap As IMap, ByVal strLayerNameVector As String, ByVal IntCellSize As Integer)
        Try
            '1- Récupération de la couche vecteur
            If pMap Is Nothing Then
                MessageBox.Show("Fonction CreateFishnet : IMap n'est pas récupéré.")
                Exit Sub
            End If

            Dim lngIdLayer As Long = 0
            lngIdLayer = FindIdLayerByName(strLayerNameVector, pMap)

            Dim player As ILayer2
            player = pMap.Layer(lngIdLayer)

            If player Is Nothing Then
                MessageBox.Show("Fonction CreateFishnet : ILayer n'est pas récupéré.")
                Exit Sub
            End If

            Dim pflayer As IFeatureLayer
            pflayer = CType(player, IFeatureLayer)

            Dim pFclass As IFeatureClass
            pFclass = pflayer.FeatureClass

            Dim pDataset As IDataset = CType(pFclass, IDataset)

            Dim pGeoDS As IGeoDataset
            pGeoDS = CType(player, IGeoDataset)

            Dim pSpatialReference As ISpatialReference
            pSpatialReference = pGeoDS.SpatialReference

            Dim strSpatialReference As String = pSpatialReference.Name

            Dim pEnvelope As IEnvelope = pGeoDS.Extent

            '2- dimensionnement de l'enveloppe pour le fishnet
            Dim dbl_Right As Double = pEnvelope.XMax
            Dim dbl_Left As Double = pEnvelope.XMin
            Dim dbl_Top As Double = pEnvelope.YMax
            Dim dbl_Bottom As Double = pEnvelope.YMin

            'attribution des paramètres coordonnées
            Dim dbl_coordX As Double = dbl_Left
            Dim dbl_coordY As Double = dbl_Bottom
            Dim dbl_OppositeCornerX As Double = dbl_Right
            Dim dbl_OppositeCornerY As Double = dbl_Top

            'détermination du nb de lignes et de colonnes
            Dim dbl_Longueur As Double = 0.0
            Dim dbl_largeur As Double = 0.0

            If dbl_Left < dbl_Right Then
                dbl_Longueur = dbl_Right - dbl_Left
            ElseIf dbl_Left > dbl_Right Then
                dbl_Longueur = dbl_Left - dbl_Right
            End If
            dbl_largeur = dbl_Top - dbl_Bottom

            Dim dbl_nbLignes As Double = 0.0
            Dim dbl_nbColonnes As Double = 0.0
            dbl_nbLignes = dbl_largeur / IntCellSize
            dbl_nbColonnes = dbl_Longueur / IntCellSize
            Dim int_nbLignes As Integer = CInt(dbl_nbLignes)
            Dim int_nbColonnes As Integer = CInt(dbl_nbColonnes)

            '3- définition des points nécessaires à la création du fishnet (maillage)
            Dim pPointOriginCoord As IPoint = New Point
            pPointOriginCoord.X = dbl_Left
            pPointOriginCoord.Y = dbl_Bottom
            Dim pPointYaxisCoord As IPoint = New Point
            pPointYaxisCoord.X = dbl_Left
            pPointYaxisCoord.Y = dbl_Bottom
            Dim pPointCornerCoord As IPoint = New Point
            pPointCornerCoord.X = dbl_Right
            pPointCornerCoord.Y = dbl_Top

            '4- Create a feature class
            Dim FeatureClassName As String = "test_code.shp"
            Dim pWorkspace As IWorkspace = pDataset.Workspace
            Dim featureWorkspace As IFeatureWorkspace = CType(pWorkspace, IFeatureWorkspace)
            ' Instantiate a feature class description to get the required fields.
            Dim fcDescription As IFeatureClassDescription = New FeatureClassDescriptionClass()
            Dim ocDescription As IObjectClassDescription = CType(fcDescription, IObjectClassDescription)
            Dim fields As IFields = ocDescription.RequiredFields
            Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)

            ' Add a Name text field to the required fields.
            Dim field As IField = New FieldClass()
            Dim fieldEdit As IFieldEdit = CType(field, IFieldEdit)
            fieldEdit.Name_2 = "Name"
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeString
            fieldsEdit.AddField(field)

            ' Use IFieldChecker to create a validated fields collection.
            Dim fieldChecker As IFieldChecker = New FieldCheckerClass()
            Dim enumFieldError As IEnumFieldError = Nothing
            Dim validatedFields As IFields = Nothing
            fieldChecker.ValidateWorkspace = CType(featureWorkspace, IWorkspace)
            fieldChecker.Validate(fields, enumFieldError, validatedFields)

            ' The enumFieldError enumerator can be inspected at this point to determine
            ' which fields were modified during validation.
            ' Create the feature class.
            Dim featureClass As IFeatureClass = featureWorkspace.CreateFeatureClass(FeatureClassName, validatedFields, _
                                                ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, _
                                                fcDescription.ShapeFieldName, "")

            '5- Create Fishnet
            Dim pCreatefishnet As ESRI.ArcGIS.DataManagementTools.CreateFishnet = New CreateFishnet()
            pCreatefishnet.out_feature_class = featureClass
            'pCreatefishnet.template = pGeoDS.Extent
            'pCreatefishnet.corner_coord = pPointCornerCoord 
            pCreatefishnet.origin_coord = pPointOriginCoord
            pCreatefishnet.y_axis_coord = pPointYaxisCoord
            pCreatefishnet.cell_height = CDbl(IntCellSize)
            pCreatefishnet.cell_width = CDbl(IntCellSize)
            pCreatefishnet.number_rows = int_nbLignes
            pCreatefishnet.number_columns = int_nbColonnes
            pCreatefishnet.labels = True
            pCreatefishnet.geometry_type = esriGeometryType.esriGeometryPolygon

            Dim pGpProcess As ESRI.ArcGIS.Geoprocessor.IGPProcess
            pGpProcess = CType(pCreatefishnet, ESRI.ArcGIS.Geoprocessor.IGPProcess)

            Dim pExecGeoprocess As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
            pExecGeoprocess.Validate(pCreatefishnet, True)
            RunToolBoxGeoprocess(pExecGeoprocess, pGpProcess, Nothing)

        Catch ex As Exception
            MessageBox.Show("Fonction CreateFishnet : " & ex.Message)
        End Try
    End Sub

    Public Shared Sub RunToolBoxGeoprocess(ByVal geoprocessor As ESRI.ArcGIS.Geoprocessor.Geoprocessor, ByVal process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ITrackCancel)
        geoprocessor.OverwriteOutput = True
        geoprocessor.AddOutputsToMap = True
        Try
            geoprocessor.Execute(process, Nothing)
        Catch ex As Exception
            MessageBox.Show("Fonction RunToolBoxGeoprocess : " & ex.Message)
        End Try
    End Sub


Error running the GeoProcessor from a Windows Service (Network Service)

$
0
0
Hello,

I've created a simple Windows Service application in VC++, which all it does is call the GeoProcessor:

IGeoProcessorPtr ipGP(CLSID_GeoProcessor);
ipGP->SetEnvironmentValue(L"workspace",_variant_t(L"C:\\Temp\\MapsTemp\\GDT"));
IVariantArrayPtr ipValues(CLSID_VarArray);
ipValues->Add("C:\\Temp\\MapsTemp\\GDT");
ipValues->Add("mySERVgdb");
IGeoProcessorResultPtr ipResult;
ITrackCancelPtr trcl(CLSID_TrackCancel);
ipResult = ipGP->Execute(L"CreatePersonalGDB", ipValues, trcl);

If this service is run as the default 'Local Service' user then it works fine. However, when it is run as 'Network Service' it fails and crashes the service.

A red-x windows MSVC++ Debug Library dialog appears saying:
Debug Error!
Program: Myprogram.exe

R6010
- abort() has been called

(Press Retry to debug the application)
Abort, Retry, Fail

The service then stops, and the geodatabase is not created. I have put logging in and it works ok up to the GP->Execute.

The Network Service user has been given full permission on the folders in question.

This is something we have done in the past with 9.3 and it has worked fine, but doesn't seem to work in 10.

Any help would be appreciated.

thanks

Matt

How do you check if a layer in TOC is a vector or a raster/image? vb.net

$
0
0
I am writing code for a button in a windows.form to export to KMZ any selected features from any vector layer in a maps TOC.
Code works well with vector layers but seems to crash if there is any imagery or raster in the TOC.
I understand that Ifeaturelayer is for vector geometries only, so I am guessing I need to include a check if the current layer is a vector, if so continue with code, otherwise skip the code. But being very new to arcobjects, I cant figure out how to do this?

See below:

Public Sub ExportSelectedFeaturesToKML()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFeatureLayer As IFeatureLayer
Dim LayerName As String


pMxDoc = My.ArcMap.Document
pMap = pMxDoc.FocusMap

'Counts number of Layers in TOC

Dim LayerCount As Integer
LayerCount = pMap.LayerCount


'******** Loops through layers in TOC and checks if there are any selected features, if so exports them as KMZ.


For i = 0 To LayerCount - 1

pFeatureLayer = pMap.Layer(i)

'Determines the Name of current Layer for KMZ file name
LayerName = pMap.Layer(i).Name


'Calculates current date and time and provides as a string
Dim rightNow As DateTime = DateTime.Now
Dim strCurrentDateTimeString As String
strCurrentDateTimeString = rightNow.ToString("ddd_dd_MMM_yyyy_hh_mm_ss_tt")

'Checks if layer has any selected features
Dim pLayer As ILayer
pLayer = pMap.Layer(i)

Dim pFeatureSelection As IFeatureSelection
pFeatureSelection = pLayer

Dim PSelectionSet As ISelectionSet2
PSelectionSet = pFeatureSelection.SelectionSet

Dim SelectionCount As Integer
SelectionCount = PSelectionSet.Count

If SelectionCount > 0 Then

' Initialize the geoprocessor.
Dim GP As Geoprocessor = New Geoprocessor()

Dim LayerToKMLTool As ESRI.ArcGIS.ConversionTools.LayerToKML = New ESRI.ArcGIS.ConversionTools.LayerToKML()
GP.SetEnvironmentValue("workspace", "C:\Data")
LayerToKMLTool.layer = pFeatureLayer
LayerToKMLTool.layer_output_scale = 1
LayerToKMLTool.out_kmz_file = LayerName & "_" & strCurrentDateTimeString & ".kmz"

GP.Execute(LayerToKMLTool, Nothing)
End If

Next


End Sub


Any suggestions would be greatly appreciated.
Justin

Beginner at ArcObjects - Help?

$
0
0
Hello,

I am looking for the information and resources to get me started with ArcObjects. Could someone point me in the right direction? I currently have ArcGIS 10.1 at my disposal. Thanks!

Map control in dockable window?

$
0
0
I am new to ArcObjects and looking to get some ideas on how to display raster data from a Mosaic Dataset in a separate window using an ArcMap addin. Basically the user would click (identify) a point on a Mosaic Dataset in ArcMap and a popup window would appear and load only the rasters identified (as raster datasets probably). I am a little lost with how to go about this (Dockable Window or MapViewerWindow?) so any help/ideas for a basic workflow would be much appreciated.

Reloading a local raster layer from disk

$
0
0
Hi,

I am creating a raster layer in ArcMap 10.1 and displaying it in the map:

CComPtr<IRasterLayer> iRasterLayer;
iRasterLayer.CoCreateInstance(CLSID_RasterLayer);
iRasterLayer->CreateFromFilePath(rasterFile);
m_pMap->AddLayer(iRasterLayer);

The file on disk that is at the rasterFile location is later changed by some other software and I want the map to reflect that change. I have tried many different approaches with no success. For example, I tried the obvious which was to remove the raster layer from the map, then create a new raster layer as in the code above. Even in that case, it still displays the OLD image, not the updated one. I am assuming there is some cacheing going on that is based strictly on the filename. My only recourse has been to restart ArcMap which of course is not an acceptable workaround.

Does anyone have any advice? My preference is to do something at the original RasterLayer object level (e.g. telling it to reload/clear cache, etc.), but anything short of restarting ArcMap would be an improvement.

BTW, this issue is not specific to ArcObjects. I can reproduce the same behavior by adding the raster file interactively via the ArcMap GUI, removing the layer, updating the file, then adding the file via the GUI again. But, I am hoping there is something I can call in ArcObjects to address this issue.

Thanks,
Kyle

New to ArcObjects 10

$
0
0
Having trouble creating custom buttons for 10.0 from 9.3.
I know most of my code will work, but when I run the snippits:
GetMxDocumentFromArcMap & GetActiveVewFromArcMap both return Nothing.

So it's impossible to do anything further when you can't get a valid reference to the MxDoc or Active view.


My previous code used to have:
Private m_application As IApplication
But in 10.0 I get an error with that line and changed it to:
Private m_application As ESRI.ArcGIS.Framework.IApplication

Could somebody post some sample code or sample project to help me get started??

Thanks

Help - Geoprocessing libraries from stand-alone .net application built with ArcEngine

$
0
0
Hi,

We have a map viewer built using the ArcEngine map controls, and now I'd like to start using some of the Geoprocessing tools to generate layers for display in the map viewer.

I'm wondering if I can use the ESRI.ArcGIS.DataManagementTools library (eg. FeatureToPolygon tool) from a stand-alone .net application built on ArcEngine and deployed to a target machine that only has an ArcEngine Run-time license?

To make matters worse, the help topics on this site are showing "Document not found" for several of the links under the "Geoprocessor library and tool reference".

Can all of these tools under the "Geoprocessing library and tool reference" be used with an ArcEngine Run-time license? (Excepting the obvious ones that require additional extensions like Spatial Analyst).

After navigating much of the online documentation I've come to the conclusion that using the above library within ArcGIS requires the Advanced license level (ArcInfo). But I'm hoping the full functionality is opened with the ArcEngine Run-time licensing.

Thank you so much for your assistance, and sorry if this was confusing.

ArcObject: Rotation Tool Issue

$
0
0
Hi All,

I am adding "Rotate Tool" in tool bar with "Start editing","Save Edits", "Stop Editing" and "Edit Tool". Can any one help me please.

Here is the scenorio

1. Start editing
2. After start editing "Edit tool" is enable but "Rotate Tool" is not enable.
3. Other thing working fine.

Thanks in advance.
Sajid

help me ! there are error when executing IZonalOp.ZonalStatisticsAsTable

$
0
0
When I use tool zonalstatistics as table or zonstatistics in ArcToolBox 10.1,I can get the result without error.
But when I use C# and IZonalOp.ZonalStatisticsAsTable( or pZonalOp.ZonalStatistics ) in ArcObjects 10.1,There are error as follows:
ERROR 010316: Unable to open the input raster: C:\USERS\ADMINI~1\APPDATA\LOCAL\TEMP\G_G722
ERROR 010067: Error in executing grid expression.

I have read many posts,but no one can...:(
My codes are listed as follows.Help Me!

Code:

ISurfaceOp2 pSurfaceOp = new RasterSurfaceOpClass();
object Missing = Type.Missing;
IRasterDataset rasterDataset = default(IRasterDataset);
rasterDataset = pdemWorkspace.OpenRasterDataset(demName);//"SDE.Slope_SDE1"
IGeoDataset pdemGeoDs = (IGeoDataset)rasterDataset;
IGeoDataset pOutputRaster = pSurfaceOp.Slope(pdemGeoDs, esriGeoAnalysisSlopeEnum.esriGeoAnalysisSlopeDegrees, ref Missing);//生成坡度图generate a slope map
IFeatureClass pgridfeatClass = default(IFeatureClass);
 pgridfeatClass = pgridWorkspace.OpenFeatureClass(gridName);
IGeoDataset pgridDs = pgridfeatClass as IGeoDataset;
IZonalOp pZonalOp = new RasterZonalOpClass();
ITable pTable = pZonalOp.ZonalStatisticsAsTable(pgridDs, pOutputRaster, true);//Error occurs

Export in C# the mapserver.json file

$
0
0
Any idea of how to export in C# the mapserver.json file which is include in the tile paquage ?

With Desktop 10.1, is there a way to change the JVM runtime?

$
0
0
Prior to ArcGIS Desktop 10, the Java Configuration Tool allowed one to specify an alternate JVM (http://resources.esri.com/help/9.3/a...7bdc50d4d1.htm). In 10.1 that is no longer an option, as far as I can tell. I noticed that between 10.0 and 10.1 the JRE rolled back one update. I'm noticing some issues w/ a Java add-in I created that works fine in 10.0, and I would like to rule out the JVM change. Can I change the default JVM setting? Thanks in advance, cg.

Looking for video tutorials/courses for ArcObjects/ArcEngine?

$
0
0
Hi all
As it's clear from title, i'm looking for a video courses for ArcObjects/ArcEngine Programming to download or purchase. There are some videos in arcgis.com, but they are spare and they are not step-by-step and don't follow a specific goal.
I also aware of some classes, but i don't wanna take part in class. just to have videos in my hand.
If you know any, That would be kind of you if you inform me.

Regards
Viewing all 1374 articles
Browse latest View live