How to get a list of Class Extensions installed on PC?

3528
3
Jump to solution
07-29-2015 10:01 AM
TimDine
Occasional Contributor II

I'm building a geoprocessing tool which allows Class Extensions to be applied to and removed from an object in the geodatabase.  Works great, it's in a custom toolbox with user defined input parameters.  If I know the guid of a class extension I can apply it.

Exert from set execute function

ITable theITable = _utils.OpenTableFromString(thePath);
IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)theITable;
if (classSchemaEdit == null)
{
     message.AddMessage("The selected object does not contain and/or support extension classes.");
}
else
{
     message.AddMessage("The extension class is being set on the selected object");
     ISchemaLock schemaLock = (ISchemaLock)classSchemaEdit;
     //Need an exclusive schema lock on the class.
     schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
     classSchemaEdit.AlterClassExtensionCLSID(theGUIDUID, null);
     schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}

Exert from ParameterInfo section of tool.

//Could write some code here to pull this list of codes from the geodatabase 
IGPCodedValueDomain pGUIDDomain = new GPCodedValueDomainClass();
pGUIDDomain.AddStringCode("{A GUID GOES HERE}", "Test Class 1");
//pAccumulatorsDomain.AddStringCode("Meters", "Meters");
IGPParameterEdit3 theInputGUID = new GPParameterClass();
theInputGUID.DataType = new GPStringType();
theInputGUID.Value = new GPStringClass();
theInputGUID.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
theInputGUID.DisplayName = "Input GUID";
theInputGUID.Name = "inputGUID";
theInputGUID.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
theInputGUID.Domain = (IGPDomain)pGUIDDomain;
parameters.Add(theInputGUID);

In there future rather than have the guids hardcoded or in a config file I'd like to find the class extensions that I could apply in the code that I can then populate into a user pick list in the tool.  I don't know how to find the list of extensions.  I'd rather get a list of class extensions on the PC rather than applied in the geodatabase.  Narrowing the list to custom ones would be ideal but not necessary.  It isn't meant to be run by generic users, only administrators.  Thoughts?

0 Kudos
1 Solution

Accepted Solutions
ChrisKushnir
New Contributor III

Like just about everything else, there is a COM category for that.

You have possibly 3 or more choices of how to get the extensions:

1) If you have ArcFM installed you can use MMCategoryFactoryClass which will allow you iterate through the extension GUIDs, or create instances of the extensions and get the names from the instances.

2) Use the rather limited ArcObjects CategoryFactoryClass to create instances of the extensions, and get the names from the instances.

3) Drop down to .NET or Win32 and query directly e.g. Using the COM Component Categories Manager in .NET - CodeProject

View solution in original post

3 Replies
ChrisKushnir
New Contributor III

Like just about everything else, there is a COM category for that.

You have possibly 3 or more choices of how to get the extensions:

1) If you have ArcFM installed you can use MMCategoryFactoryClass which will allow you iterate through the extension GUIDs, or create instances of the extensions and get the names from the instances.

2) Use the rather limited ArcObjects CategoryFactoryClass to create instances of the extensions, and get the names from the instances.

3) Drop down to .NET or Win32 and query directly e.g. Using the COM Component Categories Manager in .NET - CodeProject

TimDine
Occasional Contributor II

This particular situation I don't have ArcFM.  This is a new custom class extension that populates an attribute with some custom code depending on various things, similar to an ArcFM autoupdater.

I found a good ArcGIS sample based on your option two which worked perfectly.  It now gets guid and name from the TYPE object of the objectCategory and populates them into the domain used by the tool's input parameter.  Now if new classes are added in the future they won't be hardcoded in the tool.

               IGPCodedValueDomain pGUIDDomain = new GPCodedValueDomainClass();


               //pGUIDDomain.AddStringCode("{hardcoded GUID}", "Extension 1");
               //pGUIDDomain.AddStringCode("{hardcoded GUID}", "Extension 2");

                // Set up GUID object for the desired component category
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "{D4E2A322-5D59-11D2-89FD-006097AFF44E}"; //GUID of the Class Extension Category

                ESRI.ArcGIS.esriSystem.ICategoryFactory categoryFactory = new ESRI.ArcGIS.esriSystem.CategoryFactoryClass();
                categoryFactory.CategoryID = (ESRI.ArcGIS.esriSystem.UID)uid;

                object object_Category = categoryFactory.CreateNext();
                while (object_Category != null)
                {
                    Type theType = object_Category.GetType();
                    pGUIDDomain.AddStringCode("{"+theType.GUID.ToString()+"}", theType.Name.ToString());
                    object_Category = categoryFactory.CreateNext();
                }

HarshitaGupta1
New Contributor II

Hi,

I am facing an issue while running a script in Python i.e. 

ERROR 000229: cannot open feature class.

Unable to create object class extension COM Component

Failed to execute(Make Feature Layer)

 The feature class is in File Geodatabase. I am able to open the feature class in ArcMap and Arc Catalog.

0 Kudos