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

AttributeError: 'module' object has no attribute 'CreateFileGDB_Management'

$
0
0
I keep getting this error, and don't understand why. Here's my code:

Code:

# Import ArcPy site-package and os modules
import os
import sys
import arcpy

#Set variables
root_directory ="C:\\Users\\Me\\Documents\\ArcGIS\\Test2\\"
arcpy.env.workspace = root_directory

#Create Terminal clips gdb
terminal_db = "2014-05 Terminal Clips.gdb"
arcpy.CreateFileGDB_Management(root_directory, terminal_db)

I've tried removing the trailing "\\" from root_directory and also replacing the root_directory and terminal_db variables with the string literals, but still get the same results.

I googled the error, and it looks like it means that CreateFileGDB_Management doesn't exist. People had the attribute error for other classes/functions and the problem was that it was spelled incorrectly or the capitalization was off. However, I copied this directly from http://resources.arcgis.com/en/help/...0000000v000000. I am using arcGIS 10.2, for the record.

What am I missing?

Menu - onCreate Event

$
0
0
Dear All,

The Class 'BaseCommand' has 'OnCreate' method(to handle oncreate event). Similarly is there any equivalent method available for Menu ('BaseMenu' Class)?

TOCControl AddLayer...

$
0
0
When adding a layer to the TOCControl (in ArcGIS Engine), the layer is shown with symbology beneath it. You can collapse and expand the symbology by clicking the plus or minus icon on the left. The default is expanded mode. Is there a way to add a layer, but the symbology is collapsed? If we add a lot of layers it becomes cumbersome to collapse each one except the ones we are interested in.

Thanks,
Joe

Access Add-in Button.Caption in Code

$
0
0
Dear all,

Can anybody tell me how to read the Caption, Message and Tooltip properties of an ArcMap Add-in Button programmatically? The properties are defined in the Config.esriaddinx file and are shown correctly in ArcMap. However, when I try to query them, say, in the Button's OnClick method, I only get an empty string:

Code:

    public class DummyButton : Button
    {
        protected override void OnClick()
        {
            MessageBox.Show(string.Format("Button '{0}' was clicked!", this.Caption));
        }
    }

On the other hand, it is possible to change the properties Message and Tooltip programmatically, and the update is reflected both in ArcMap and in code. The Caption can be changed too and will be available in code, although in ArcMap the button's caption won't be updated. But how to get the values that are defined in the config file? Btw, I'm using ArcGIS for Desktop 10.2.

Thanks for any hints,
Fridjof

Error when calling IIndexQuery2.Within

$
0
0
Using a street centerline feature class and a polygon feature class, I am taking the shape of a street polyline and attempting to get all of the polygon shapes that this polyline is within. I am using IIndexQuery2.Within(feature.shape), and I DO have an index built on the polygon layer. When I pass in different polyline shapes, sometimes I get results and sometime an error is thrown. The error is:

Exception: System.Runtime.InteropServices.COMException (0x80041538): Exception from HRESULT: 0x80041538
at ESRI.ArcGIS.Carto.FeatureIndexClass.IIndexQuery2_get_Within(IGeometry pShape)

I checked for null geometries in the polygon layer and there were none. What else could be causing this error?
Thank you!

How to select datagridview rows based on selected features?

$
0
0
Hi all
I've used sample "Bind a geodatabase table to .net control" to show attribute table of feature layers in a datagridview.
Now, i wanna update that datagridview when user selects some features in map and select corresponding rows.
Is there any code or sample for that? I've searched all internet but no help.

Regards

layer names to text box using C#

$
0
0
Hi, I am trying get layer names to text box but i am not getting result.Here is my code
Can any one help

IMxDocument imx = m_application.Document as IMxDocument;

IMap map = imx.FocusMap;
StreamWriter sw = new StreamWriter("C:\\temp\\layer.txt");
ILayer layer =null;
// int lcount = map.LayerCount;
IEnumLayer player = map.get_Layers(null, false);
for (int i=0;i<map.LayerCount;i++)
layer = player.Next();

while (player!=null)

{

sw.WriteLine(layer.Name);
layer = player.Next();
}

}

Geoprocessor - C# - Create empty feature class using template for attribute fields

$
0
0
Hello,

I am using the ArcObjects SDK - C# and geoprocessor to create an empty polyline featureclass in a file geodatabase. This feature class will use an existing feature class in the file geodatabase as a template for its' fields.

I can get this to work ok using Python, however when I run my C#/ArcObjects code the required fields are not being created from the template. The output created only has the default featureclass attributes - OBJECTID, Shape and Shape_Length.

Can anyone point out where I am going wrong? I think I have used the correct syntax ok from ArcGIS Geoprocessing help. The code is shown below. Any help would be much appreciated to solve a frustrating problem!

Kind Regards

Barry Mason
Senior DBA/GIS Developer
SPT



/////////////////////////////////////////////////////////////////////////////////////////

Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IWorkspace out_path = workspaceFactory.OpenFromFile(@"C:\ProfLP.gdb", 0);

IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)out_path;

string out_name = "outputTest";
string geometry_type = "POLYLINE";

IFeatureLayer pInFeatLayer = new FeatureLayerClass();
IFeatureClass pInFeatClass = featureWorkspace.OpenFeatureClass("Profile42770");
pInFeatLayer.Name = pInFeatClass.AliasName;
pInFeatLayer.FeatureClass = pInFeatClass;

string has_m = "DISABLED";
string has_z = "DISABLED";

SpatialReferenceEnvironment spatialRefEnv = new SpatialReferenceEnvironmentClass();
ISpatialReference spatial_reference = (ISpatialReference)spatialRefEnv.CreateProjectedCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRProjCSType.esriSRProjCS_BritishNationalGrid); //OSGB

string config_keyword = "";
Double spatial_grid_1 = 0;
Double spatial_grid_2 = 0;
Double spatial_grid_3 = 0;

// Create the geoprocessor.
IGeoProcessor2 gp = new GeoProcessorClass();

// Create an IVariantArray to hold the parameter values.
IVariantArray parameters = new VarArrayClass();

// Populate the variant array with parameter values.
parameters.Add(out_path);
parameters.Add(out_name);
parameters.Add(geometry_type);
parameters.Add(pInFeatLayer);
parameters.Add(has_m);
parameters.Add(has_z);
parameters.Add(spatial_reference);
//parameters.Add(config_keyword);
//parameters.Add(spatial_grid_1);
//parameters.Add(spatial_grid_2);
//parameters.Add(spatial_grid_3);

object sev = null;

// Execute the tool.
gp.Execute("CreateFeatureclass_management", parameters, null);
Console.WriteLine(gp.GetMessages(ref sev));

///////////////////////////////////////////////////////////////////////


The console output is:

CreateFeatureclass C:\ProfLP.gdb outputTest POLYLINE Profile42770 DISABLED
DISABLED "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_O
SGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0]
,UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER[
'False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Centr
al_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of
_Origin',49.0],UNIT['Meter',1.0]];-5220400 -15524400 10000;-100000 10000;-100000
10000;0.001;0.001;0.001;IsHighPrecision" # 0 0 0
Start Time: Tue Jun 17 11:02:40 2014
Succeeded at Tue Jun 17 11:02:40 2014 (Elapsed Time: 0.00 seconds)

Programmatically change the datasource of a join (IRelQuery DestinationTable ??)

$
0
0
Hello everybody

I'm trying to change the datasource of a join.
The reason for that is the following: I read the source out of an given Lyr-File, in which the path is abolute. If I load another project, I want the datasource to be the one I load, and not the one standing in the lyr. That's why I need to change that. (This Lyr thing is not important for the question but it may give you a better understanding. Otherwise the lyr can be seen as a static file which contains sources and tablenames).

For illustration:
This is the source I load. (Q:datasource\ele1_testings_fgdb\...
Attachment 34678

This is the source standing in the lyr and used for the join. (Q:\datasources\ele1_testing_mdb\...
Attachment 34679

So how it's done?

Thanks for every hint!
Attached Thumbnails
Click image for larger version

Name:	Lyr_src.png‎
Views:	N/A
Size:	50.7 KB
ID:	34678   Click image for larger version

Name:	Lyr_src_join.png‎
Views:	N/A
Size:	55.8 KB
ID:	34679  

Query for Label in VB.NET how to

$
0
0
Hi

I am new in this forum and Arcobject I need to search for Label in Arcmap Query

What do I search for in this forum to get me started with this
Or do anyone have sample how to Query for Label with VB.NET ?

1. Address or please


Regards
Sgear

How do I disconnect an open SDE direct connection?

$
0
0
I am working in an enterprise geodatabase in through Citrix - both the desktop client and SDE (Oracle 11g) are at 10.1.

I often have multiple SDE connections open in ArcCatalog and would like a way to close all of them at once rather than right clicking on each one and selecting disconnect. I don't see any close or disconnect methods and the 'ClearWorkspaceCache_management' method does not close the connection in the ArcCatalog tree.

Does anyone know if there is a way to do this using ArcObjects?

Thank you

ArcMap.Application is null when Addin is loaded

$
0
0
Hello,

I've a problem in the installation of an Add-in that we've developed for our client. The Add-in does not work correctly because the ArcMap.Application value is null when loaded. The type of this Add-in is an Extension.

The Add-In is developed with ArcObjects in the version of 10.2.1. We don't have any problem when it is tested on our environment with an ArcMap 10.2.1. Our client has a version of 10.2.0.

Does any one has an idea of this error ?

Thank you very much.

Siqin

Need Help in ArcEngine 10.2 Application Deployment in windows 7

$
0
0
I developed an application using ArcEngine 10.2. Anyone have an idea on how to deploy the application to the other pc w/o using my ArcEngine License? I tried installing the app to a computer with ArcGIS Desktop 10.2 license and it worked. But i want to install it to a computer w/o ArcGIS Desktop / ArcGIS Engine License. Anyone know what license to use? Please help me.

Regards,
zxin

Extensions window not refreshing when programatically changed

$
0
0
I have a few extensions (3 and growing) that implement IExtensionConfig. The extensions are for doing different sorts of task in ArcMap, so they rely on different data loaded, enable different custom tools etc. I only want one extension enable at the time. So I added logic in IExtensionConfig.state set to check the state of the other extension when a user turns the extension on and display a message an disable the extension. That is fine but the extension window is not refreshed. If I close and reopen it, it appears correctly.

This is similar to this thread but it is not add-ins and that thread didn't have an answer.
http://forums.arcgis.com/threads/520...xtensionConfig

How to I get the window to refresh?

How to create ArcGIS Toolbox built-in tools using ArcObjects?

$
0
0
Hello - I am in a situation where my Python arcpy scripts are limited (the arcpy API is limited I should say) so I can't create a satisfactory script tool and I can't use a model to create a tool I want because some of the things I need aren't found in the Esri built-in toolboxes. That leaves me with needing to create my own tool using ArcObjects and making that available in my toolbox as a custom built-in tool. My problem is that I can't seem to find any documentation that tells me how to take my ArcObject classes and make them available as a built-in tool that I can add to my toolbox. I hope I explained that coherently. Any thoughts on how I may go about doing this??

Thanks - Peter

GeodatabaseUI.ICalculatorUI2 no longer works in ArcMap 10.1

$
0
0
I have an addin that has been ported from ArcMap 9.3 to 10.1 and this code worked perfectly in 9.3 but for some reason won't work at all in 10.1:

Code:

ICalculatorUI calc = new CalculatorUI();
calc.Table = MyTable;
calc.Field = "MyField";
calc.DoModal(ArcMap.Application.hWnd);

The actual code is a little more complicated than that, but I've tried it with this simplified version and it still doesn't work.

What happens is the calculator dialog pops up just fine and I can enter a value to set the field to, but when I hit the OK button, the dialog closes without error, but nothing has been updated.

I've opened the table that I'm editing using ArcMap's regular ui and launched the Field Calculator on the same field and can confirm that it looks exactly like what I see when I use this bit of code on my own form. There are only three differences:
  • Prior to the dialog displaying, there's a warning dialog that pops up telling me that I'm not in an editing session and the changes can't be undone.
  • After the OK button is pressed, a progress dialog shows briefly while the rows are being updated.
  • The rows are actually updated.

So everything that is displayed on the dialog itself is identical, including the name of the field and the list of other fields in the table.

In ArcMap 9.3, the `ICalculatorUI` would take over everything as soon as `DoModal` was called. It annoyingly didn't even provide feedback programmatically to signify if the user canceled the dialog or [if/how many] rows were updated. Very black box and it sucked, but at least it worked!

I've not been able to find any help on this anywhere, especially not on ESRI's pathetic documentation, which appears to be copied and pasted from their 9.x documentation. I've also posted this question on StackOverflow, but haven't gotten any responses there either and it's been almost two weeks...

I have people waiting on this, so any help would be greatly appreciated. Thanks.

Multiple parts of a polyline M

$
0
0
In a SOE application, I have retrieve all of points broken from a polyline M if it is a single part segment. If a segment contains multiple parts, how to retrieve the parts as well as the points using ArcObjects? Thanks if you can share your experience.

C# Release Excel Objects

$
0
0
I have an application written in C# that runs from within ArcMap and it creates an Excel file on the fly using Microsoft.Office.Interop.Excel objects.

It works fine except the Excel process hangs until you close ArcMap.

In the code I save and close the workbook object, quit the Excel application object and then do a Marshal.ReleaseComObject on them.

I thought this was supposed to terminate the Excel process but that doesn't happend until ArcMap is closed.

I had a VB6 version of this application and in that case I did a save and close on the workbook object, quit the Excel application object and set them all = Nothing. This worked as the Excel process ended when the application completed running, you didn't have to close ArcMap.

So... anybody know what else I have to do in C# to make the Excel process terminate, without closing ArcMap?

Thanks.

vb.net arcgis add in, log4net does not work by installing esriAddIn

$
0
0
Hi everybody,

I want to use log4net in my vb.net for ArcGIS add-in. After I build the solution, it generates a .exe file and a .esriAddIn file.
The problem is when I run the .exe file (without open ArcMap), the log4net works, but when I install the .esriAddIn in ArcMap, and call a form from ArcMap, the log4net doesn't work at all.

I check from internet but most of the answers are talking about c#.net, this problem call me crazy, anybody has the experience of using log4net in vb.net ArcGIS add in?

Any help will be appreciated. thanks.

Define a query for joining data

$
0
0
Hey around,

I´m trying to build a query that provides access to features within a FC that intersect a given geometry AND that apply to an attribute-based query from another table by a join. For the last one I may use the IQueryDef-interface as it allows joining data based on an attribute-based query, but I need both - a spatial and a attribute-component. Is there any better way then creating one of the filters first, looping the results and checking every feature for the second condition? Maybe by building a temporary table using IQueryTable from the QueryDef-object and than perform a spatial query on it?

Thanks in advance :D
Viewing all 1374 articles
Browse latest View live