POST
|
Thanks syamarth for reply. My code looks like this: 1. First I get all selected items in ArcCatalog IGxApplication gxApp = m_application as IGxApplication;
IGxSelection gxSel = null;
IEnumGxObject enumGxObj = null;
IGxObject gxObj = null;
gxSel = gxApp.Selection;
enumGxObj = gxSel.SelectedObjects;
gxObj = enumGxObj.Next();
while (gxObj != null)
{
Tools.AddRemoveExtension(gxObj, true, "{32B73670-FF7E-4e52-A0D2-740716E011D1}");
gxObj = enumGxObj.Next();
} In Tools class I have all methodes I use to setting extension. 2. In AddRemoveExtension method I check if selected item is appropriate and then I try to get IObjectClass object: public static void AddRemoveExtension(IGxObject gxObj, bool add_remove, string GUID)
{
...
IGxDataset pGxDataSet = gxObj as IGxDataset;
IDataset pDataSet = pGxDataSet.Dataset;
IObjectClass pObjectClass = pDataSet as IObjectClass;
if(pObjectClass != null && !gxObj.Name.ToUpper().Contains("GEODB.TS_"))
try
{
ChangeClassExtension(pObjectClass, GUID, null, add_remove);
}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show(errorMsg);
}
} 3. After that I use method found by me in ESRI help (the same page you gave me in your post above) private static void ChangeClassExtension(IObjectClass objectClass, String extensionUID, IPropertySet extensionProperties, bool add_remove)
{
ISchemaLock schemaLock = (ISchemaLock)objectClass;
try
{
// Attempt to get an exclusive schema lock.
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
// Cast the object class to the IClassSchemaEdit2 interface.
IClassSchemaEdit2 classSchemaEdit = (IClassSchemaEdit2)objectClass;
if (!String.IsNullOrEmpty(extensionUID) && add_remove == true)
{
// Create a unique identifier (UID) object and change the extension.
UID extUID = new UIDClass();
extUID.Value = extensionUID;
classSchemaEdit.AlterClassExtensionCLSID(extUID, extensionProperties);
}
else
{
// Clear the class extension.
classSchemaEdit.AlterClassExtensionCLSID(null, null);
}
}
catch (COMException comExc)
{
throw new Exception("Could not change class extension.", comExc);
}
finally
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
} And yes - I have separated project with ClassExtension and the other one with all buttons to adding/removing ClassExtension and WorkspaceExtension. I think there aren't any other Applications that have reference of this Class Extension. Hi, I've tested your code with an Add-in button on Catalog. I found that IGxApplication.Selection will have the selected objected only from the Tabbed view. Because, when I debug the code, the Selection has 0 count thought I select an object class from the Tree view of the catalog. But if change my selection of the object class from Treeview to the tabbled view, the selection has the count 1 and then the class extensions got installed. They were still there after I closed and reopened the catalog. I think you got the sample code of this IGxApplication.Selection from this: then its mentioned before the code starts: "The following code demonstrates how to loop through the selected objects in the tabbed view and print their categories" so I suggest you to observe how your code is working at IGxApplication.Selection while you debug it.
... View more
06-23-2011
11:15 AM
|
0
|
0
|
194
|
POST
|
Thank you! I didn't think about creating an add/clear procedure. I assumed that I would be able to access the add function of the combo box. This is great stuff!!! Yes, Combo box add-in has "Add" function that can take both item's string and tag. I used this function in AddItem method in the Combo class and called that in the button click event.
... View more
06-22-2011
11:14 AM
|
0
|
0
|
391
|
POST
|
Hi everybody! I want to make a connection on my geodatabase to make command for selecting a specific table to view it in dataGridView but i have an error i couldn't fix it anyone can help me Code C# / /connect to the database string conString = @"Provider=Microsoft.JET.OLEDB.4.0;" +@"data source=path.gdb"; OleDbConnection conn = new OleDbConnection(conString); conn.Open(); OleDbCommand command = new OleDbCommand(); command = conn.CreateCommand(); DataSet ds = new DataSet(); conn.Open(); command.CommandText = "SELECT * FROM PrimaryCircuit"; OleDbDataAdapter adapter = new OleDbDataAdapter(command); adapter.Fill(ds); dataGridView1.DataSource = ds; Error :the Microsoft Jet database engine cannot open the file 'path.gdb'. It is already opened exclusively by another user, or you need permission to view its data. Did you check that you have opened the connection twice? I think it causes the error due to schema lock on the database.
... View more
06-22-2011
06:07 AM
|
0
|
0
|
120
|
POST
|
Thanks.......I just added a new combobox to see how the setup worked. I overlooked those properties before. I actually have another question along the same lines; however, this may be better suited for a new thread. How do I access the combobox form another component. For example if I create a button and in it's OnClick event I want to add "Hello" and "World" to the combo box. I assume I access this through the namespace of the command but am not having any luck. As always thanks for the help, James Hi, Here is the code to Add Items to a combobox add-in by clicking a Command button add-in: ////Code in Combo box class: public class combo : ESRI.ArcGIS.Desktop.AddIns.ComboBox { public static combo cb; public combo() { cb = this; } public void AddItem(string itemname) { int i = cb.Add(itemname); cb.Select(i); } protected override void OnUpdate() { } } ///Code in OnClick Event of the Command button class: protected override void OnClick() { try { combo cb = combo.cb; cb.AddItem("Hello"); cb.AddItem("World"); } catch (Exception Err) { System.Windows.Forms.MessageBox.Show("Error: " + Err.Message); } } I hope it helps, if you want to clear the items before adding a group of items, you can use cb.Clear( ) in combo class and call it in button class.
... View more
06-22-2011
06:00 AM
|
0
|
0
|
391
|
POST
|
Thank you. I looked at the Config.esriaddinx and didn't see anything about size. after reading your post I added sizeString="WWWWWWWWWWWWWWWWWW" to the config and it works perfectly. Thanks a lot! James I'm glad its working. Actually when an Add-In command of type Combobox is getting created, there are some properties to be set where the "Size String" is also one of those. If we move the mouse over "Size String" property it displays its tool tip as "The string to determine the width of the combo box on the tool bar".
... View more
06-21-2011
11:51 AM
|
0
|
0
|
391
|
POST
|
Hello all, I know this is probably a very simple question but I am stuck. I created a combo box and placed it on a tool bar. I would like to adjust the width of the combo box; however, I can't find the properties. Any help is greatly appreciated. Thanks, James Hi, From your posting, I assumed that you developed an Add-In command of type Combobox and you placed it on a tool bar, but after you checked its width, you want to adjust the width. If I'm not mistaken, you can modify the "sizeString" property of the that Command of type Combobox in the Add-In's Config.esriaddinx file. While you were creating the combobox its default value would have set to something like this: "WWWWWWW". So now you can adjust the width of that string by increasing numbering "W"s if you want to increase the width of the combobox or remove some of those "W"s if you want to decrease the width of the combobox. Hope it helps!!!
... View more
06-21-2011
10:57 AM
|
0
|
0
|
391
|
POST
|
I want to list Tables (Itables) in a form with ArcObjects, but I can't it. I'm using this code. Dim pMxDoc As IMxDocument Set pMxDoc = Application.Document Dim pTableCollection As ITableCollection Dim pMap As IMap Set pMap = pMxDoc.FocusMap Set pTableCollection = pMap Dim tabla As ITable Dim ptabla As IFeatureLayer Dim ntabla As String For i = 0 To pTableCollection.TableCount - 1 Set tabla = pTableCollection.Table(i) 'Dim pName As IName ntabla = tabla. '********* I can't get name of table lista.AddItem (ntabla) Next Cast the Table object to IClass and then cast it to IDataset to get the BrowseName of any class. No need of implementing IName then. Here is the code in C# for that: IClass cls = tabla; lista.Items.Add(TableName(cls as IDataset)); string TableName(IDataset ds) { string[] v = ds.BrowseName.Split('.'); string TableName = v[v.Length - 1].ToUpper(); return TableName ; } Let me know if you still have any problem with that code.
... View more
06-17-2011
11:55 AM
|
0
|
0
|
325
|
POST
|
Hi, Here's what I am trying to do: ITrackCancel myTrackCancel = new TrackCancelClass(); myTrackCancel.Reset(); //no problem here myTrackCancel.CancelOnClick = false; // I get a System.NotImplementedException here The exception message is "The method or operation is not implemented". Has anybody experienced this before? Do I need to do anything to the myTrackCancel beforehand so I can set those bool values? Thank You, Sukhjit Just try not to reset the TrackCancel object before setting its CancelOnClick property. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//004200000235000000 ITrackCancel.Reset: "Resets the manager after the associated operation is finished." "The Reset method should be called just before a process that may be cancelled, such as a lengthy operation, begins. The Reset method sets the state of the CancelTracker to uncancelled and returns the internal counter, which is used to update the Progressor to zero." See this example code where it doesn't implement the 'Reset' method: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/00010000001w000000.htm Let me know if it doesn't help.
... View more
06-17-2011
10:42 AM
|
0
|
0
|
373
|
POST
|
Hi all, my English isn't very good, but I hope you will understand me 🙂 I'm quite new in ESRI tools, ArcObject's and so on. At this moment we (at work) started changing ArcGis 9.3 to 10. Everything has been OK so far. But now there is one problem - Class Extension. Adding and removing I've done, but... not really. Let me explain this: I log in and then I use my command button to add (I use IClassSchemaEdit2.AlterClassExtensionCLSID() method) class extansion to selected tables. I verify that and there is what I added. But problem begins when I turn off ArcCatalog and then I turn it on once again. All added Class extansions disappeared! Why? In ArcGIS 9.3 it was easier, because one insert into appropirate table and class extension is remembered. PS. With Workspace Extension there aren't any problems like with Class Extension. Hi, I too work with ClassExtensions but your reported problem sounds weird. Can you post your code that you are using to install the class extension? I got similar problem but with Updating the code that works for Class Extensions, its working fine when I install the class extensions using ArcCatalog's Add-In Button but when I open ArcMap having the classes that got the class extensions, I did not see any updated version of Class extensions. Then I found that there is another Application Extension that I developed on ArcMap that has the reference of Class Extensions and I forgot to rebuild that Application Extension solution, so that's the reason it loads the old class extension code rather than the updated one while its starting. SO I suggest you to check are there any other Applications that have the reference of the class extensions you are working with. Did you check the schema lock stuff? It seems like when your ArcCatalog get closed, your class extensions are getting removed. I always prefer to include a logfile in the project, so I can see exactly whats going on.. So you might have ArcObjects project for Class Extensions and the other Button to install them, right? Anyways, FYI: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Creating_class_extensions/000100000201000000/
... View more
06-14-2011
06:35 AM
|
0
|
0
|
194
|
POST
|
Hi All, I have a featureclass and in which relationsihps are defined. when i insert rows i am getting an error. Can someone please help me with a sample code on 'How to insert rows in featureclass that has relationships defined'. I am using ArcEditor 9.3 and visual studio 2010(C#). Thanks in advance. Regards, Srinivasa. Can you post your code and Error description? As I understood your query, are you trying to create new features in a Feature class where that class has some relationships with some other either Feature classes or Standalone tables? Did you locate where exactly you are getting the error?
... View more
06-09-2011
10:11 AM
|
0
|
0
|
281
|
POST
|
Hi all, This one is slightly challenging ! .. I have some building polygons. I have converted them to polylines. Wherever the polygons shared a boundary there i have two polylines now with different height attribute. They are actually nothing but adjacent walls of a building which differ in height. I want to calculate the difference between these two. So basically, I want to identify all places which have duplicate polylines and then I should be able to find out the difference in their height attribute field. Any ideas would be much appreciated.. Thanks and Regards, Priyanka you can look at this old thread at forums: http://webcache.googleusercontent.com/search?q=cache:w8NeSAjc0W0J:forums.esri.com/Thread.asp%3Fc%3D93%26f%3D987%26t%3D296213+how+to+find+duplicate+lines+on+arcmap&cd=1&hl=en&ct=clnk&gl=us&client=firefox-a&source=www.google.com and also you can look at this ArcScript but try to modify it to just find the duplicates so that it wont delete the duplicate features: http://arcscripts.esri.com/details.asp?dbid=15138 and when we consider it in topology side and if you have the ArcInfo licence go through this: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=4842&pid=4834&topicname=Finding_duplicate_geometry hopefully you will get a solution!!!! Cheers!!!!
... View more
06-02-2011
05:55 AM
|
0
|
0
|
256
|
POST
|
Hello Kaspatoo, I think you misunderstood my questions below, but it was a nice consideration from you. Please note the following scenario in order to be more clear with my questions: I have four layers loaded in ArcMap 9.3 and the 3rd one called "X" I generated a form that contain a datagridview in order to preview the details of the selected X feature when a user click on the map. (same functionality as Identify tool) I want to get the "OBJECT ID" of the X feature that lies under the xy of the mouse click (polygon feature that covers the location of the mouse click) in order to query the details of the this X feature from my personal datatable and not from the layer in arcmap. I think it is possible to get the "Object Id" of the feature located under the mouse click. Isn`t it? The second think is that: I want to flash the selected feature in ArcMap programmtically, So how would be the code to do that? Please help... HI, I'm not sure about your first question but here is the code to Flash the selected feature in ArcMap (C#): Add the following Reference to your project: using System.Runtime.InteropServices; namespace Project1 { class Class1 { [DllImport("kernel32.dll")] static extern void Sleep(uint dwMilliseconds); public void FlashFeature(IFeature Feature, IMxDocument MxDoc) { try { MxDoc.ActiveView.ScreenDisplay.StartDrawing(0, (short)(esriScreenCache.esriNoScreenCache)); switch (Feature.Shape.GeometryType) { case (esriGeometryType.esriGeometryPolyline): { FlashLine(MxDoc.ActiveView.ScreenDisplay, Feature.Shape); break; } case (esriGeometryType.esriGeometryPolygon): { FlashPolygon(MxDoc.ActiveView.ScreenDisplay, Feature.Shape); break; } case (esriGeometryType.esriGeometryPoint): { FlashPoint(MxDoc.ActiveView.ScreenDisplay, Feature.Shape); break; } } MxDoc.ActiveView.ScreenDisplay.FinishDrawing(); } catch (Exception Err) { MessageBox.Show("Error : " + Err.Message); } } public void FlashLine(IScreenDisplay Display, IGeometry Geometry) { ISimpleLineSymbol LineSymbol; ISymbol Symbol; IRgbColor RgbColor; try { LineSymbol = new SimpleLineSymbolClass(); LineSymbol.Width = 4; RgbColor = new RgbColorClass(); RgbColor.Green = 128; Symbol = (ISymbol)LineSymbol; Symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; Display.SetSymbol((ISymbol)(LineSymbol)); Display.DrawPolyline(Geometry); Sleep(300); Display.DrawPolyline(Geometry); } catch (Exception Err) { LogFile.WriteLog("Error at : " + Err.Message); } } public void FlashPolygon(IScreenDisplay Display, IGeometry Geometry) { ISimpleFillSymbol FillSymbol; ISymbol Symbol; IRgbColor RgbColor; try { FillSymbol = new SimpleFillSymbolClass(); FillSymbol.Outline = null; RgbColor = new RgbColorClass(); RgbColor.Green = 128; Symbol = (ISymbol)FillSymbol; Symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; Display.SetSymbol((ISymbol)(FillSymbol)); Display.DrawPolygon(Geometry); Sleep(300); Display.DrawPolygon(Geometry); } catch (Exception Err) { LogFile.WriteLog("Error at : " + Err.Message); } } public void FlashPoint(IScreenDisplay Display, IGeometry Geometry) { ISimpleMarkerSymbol MarkerSymbol; ISymbol Symbol; IRgbColor RgbColor; try { MarkerSymbol = new SimpleMarkerSymbolClass(); MarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; RgbColor = new RgbColorClass(); RgbColor.Green = 128; Symbol = (ISymbol)MarkerSymbol; Symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; Display.SetSymbol((ISymbol)MarkerSymbol); Display.DrawPoint(Geometry); Sleep(300); Display.DrawPoint(Geometry); } catch (Exception Err) { LogFile.WriteLog("Error : " + Err.Message); } } } }
... View more
05-18-2011
08:16 AM
|
0
|
0
|
809
|
POST
|
Thanks for the help I didn't have the list control set to public so I changed this but I am still getting a null reference when I try to address it. My code was quite similar to yours (VB.NET) and I now have: Protected Overrides Sub OnClick() Dim m As imap Dim e As IEnumLayer m = My.ArcMap.Document.FocusMap e = m.Layers(Nothing, True) e.Reset() Dim layer As ILayer layer = e.Next Dim dockWindow As ESRI.ArcGIS.Framework.IDockableWindow Dim dockWinID As UID = New UIDClass() dockWinID.Value = My.ThisAddIn.IDs.pradDocWin dockwindow = My.ArcMap.DockableWindowManager.GetDockableWindow(dockWinID) While Not (layer Is Nothing) dockWindow.docwinlistbox.items.add(layer.Name) layer = e.Next End While dockWindow.Show(True) End Sub The red section holds the problem line with docwinlistbox coming out as a null - the list box is called this on the form - name property and as I mentioned before the Modifiers=Public now.. Thanks Stephen yes, there was an error at that line you wrote. You should call the docwinlistbox with the Dockablewindow class itself, not with the object on the Dockable window. For this to work, you need to create a static listbox variable on the dockablewindow class and assign the 'docwinlistbox' to it and then you can call the newly created static listbox variable to add the items. code in the dockablewindow class: public partial class pradDocWin: UserControl { public static ListBox lb; public pradDocWin(object hook) { InitializeComponent(); this.Hook = hook; lb = docwinlistbox; } } So now replace that red line in the add-in button's class with the line below: pradDocWin.lb.items.add(layer.Name) Actually you need to clear existing list box items before adding the new items when you click the Add-in button to display the results list box on the form. Other wise, when you close the form and try to redisplay the form, the list box will have duplicate entries. so you should write this code as: pradDocWin.lb.items.clear( ); pradDocWin.lb.items.add(layer.Name) hope it should work now!!
... View more
05-16-2011
05:52 AM
|
0
|
0
|
360
|
POST
|
Hi Stephen, I also work on ArcGIS10 Desktop Add-Ins. If I understand your question correctly, I hope you are looking for a form with a Listbox, which will display the results from the code you have in the Add-In button when you click it. Try to add an Add-In component(Dockable Window) to your current project where you added your Add-In button. 1.Add>Class>ArcGIS>DesktopAdd-Ins>Add-in Components>Dockable Window, fill the classname, caption etc., fields on the wizard. 2.If you observe the generated code after adding the above class, it has 2 classes one with the name you gave to the class implements 'User Control' and the other class- 'AddinImpl' class implements the 'ESRI.ArcGIS.Desktop.AddIns.DockableWindow'. The generated code takes care of linking the UserControl to the DockableWindow. ( you can just change the created class' Implementation from UserControl to 'Form' if you like) 3. Now write a Static method to do what ever you want to deal with the form.Listbox. 4. Add the code to call the Dockable window in the Button Add-In's 'OnClick()' method as: public class ButtonAddIn : Button { IDockableWindow dwForm; protected override void OnClick() { UID id = new UIDClass(); id.Value = ThisAddIn.IDs.DockableWindow; // you can see the list of Add-In classes after you write 'IDs.' and select the window you want to display that has the list box. if (dwForm == null) { dwForm = ArcMap.DockableWindowManager.GetDockableWindow(id); } if (dwForm == null) return; //Call the method you wrote it in the Form to display the List box results here: DockableWindow1.Method1( ); // or you can directly write the code to display the results in the list box here itself when you change the ListBox1's 'Modifiers' property to 'Public' and then write the code as: DockableWindow1.Listbox1.Items.Add("Resulsts:"); dwForm.Show(!dwForm.IsVisible()); //To toggle the window on clicking the button } } Hope it helps and if you still have any problems, please let me know. You can see the sample code in the links below but you may get confused as it has lot of implementations on the project that includes 'Tools', 'Extensions', etc.,, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Custom_selection_extension/0001000003w2000000/ For the dockable window code: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Custom_selection_extension/0001000003w2000000/ For the Add-In Button code: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Custom_selection_extension/0001000003w2000000/ Good luck! Hi I can't figure how to write the output after pressing a button to a form within my project, can anyone help with this? I tought it ould be as simple as either addressing the dockable window (DocWindow) and then the listbox (lstResults) control but I just can't get it to work. Any help appreciated. Stephen
... View more
05-13-2011
06:30 AM
|
0
|
0
|
360
|
POST
|
Hi, You dont need to define any eventhandlers, you can try directly the inbuilt 'IActiveViewEvents_Event' interface from Carto library and call the 'FocusMap Changed' event on map. try this code: (I'm working with ArcGIS 10 now, so the code is relevant to 10 APIs) ESRI.ArcGIS.Carto.IActiveViewEvents_Event avEvent = ArcMap.Document.FocusMap as ActiveViewEvents_Event; avEvent.FocusMapChanged += new ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler(avEvent_FocusMapChanged); and now you can write what ever you want to implement on focus map changed. void avEvent_FocusMapChanged) { //....code to do what ever you like to.. } Let me know if you you still have any question on it. Thanks!
... View more
12-06-2010
05:56 AM
|
0
|
0
|
144
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|