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
|
0
|
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
|
10
|
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
|
3
|
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
|
10
|
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
|
10
|
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
|
10
|
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
|
15
|
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
|
20
|
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
|
0
|
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
|
2
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|