How to get all assembly codes and descriptions

How to get all assembly codes and descriptions

Anonymous
Not applicable
3,504 Views
5 Replies
Message 1 of 6

How to get all assembly codes and descriptions

Anonymous
Not applicable

Hi! I need to retrieve all assembly codes and descriptions of my model.

As far as I know, each Assembly Code/Description is a ClassificationEntry and those are stored in a KeyBasedTreeEntriesLoadContent object.

 

I was trying this, but I think I need to initialize the KeyBasedTreeEntriesLoadContent object. The problem is that there's no constructor...

 

UIApplication uiapp = commandData.Application;
Document doc = uiapp.ActiveUIDocument.Document;

KeyBasedTreeEntriesLoadContent content = null;
ClassificationEntries.LoadClassificationEntriesFromFile(doc.PathName, content);

foreach (ClassificationEntry elem in content.GetEntries())
{
//Does something with each elem
}

 

Thank you in advance.

 

0 Likes
Accepted solutions (1)
3,505 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

I found a solution for my problem. It turns out those values are included as parameters of element types.

You can iterate through each element type and do:

 

string assemblyCode = elementType.get_Parameter(BuiltInParameter.UNIFORMAT_CODE).AsString();

string assemblyDescription = elementType.get_Parameter(BuiltInParameter.UNIFORMAT_DESCRIPTION).AsString();

 

I still don't know if there's better way to get all of them directly, without iterating though all the elements, but this works for my problem as I already need to iterate through them.

0 Likes
Message 3 of 6

FrankHolidaytoiling
Advocate
Advocate

Hi,

How to do this inside of a family editor

0 Likes
Message 4 of 6

Hominis06
Explorer
Explorer

ClassificationEntries.LoadClassificationEntriesFromFile() provides you to load the contents from classification text file into the provided KeyBasedTreeEntriesLoadContent (as revitapidocs.com says)

 

To get all assembly codes and descriptions use this:

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;
            AssemblyCodeTable assemblyCodeTable = AssemblyCodeTable.GetAssemblyCodeTable(doc);
            ClassificationEntries classificationEntries = assemblyCodeTable.GetKeyBasedTreeEntries() as ClassificationEntries;
            foreach (ClassificationEntry entry in classificationEntries)
            {
                string assemblyKey = entry.Key;
                string assemblyDescription = entry.Description;
                //do your stuff
            }

            return Result.Succeeded;
        }

 

Message 5 of 6

c_hanschen
Advocate
Advocate

This is a nice way to get all the content (Key and Description) from the AssemblyCodeTable.

 

How can I find the filename of the loaded Assembly Code File? (so the *.txt file)

 

I want to be able to check if the correct file is loaded in the project.

 

Thanks in Advance,

 

Chris Hanschen

LKSVDD architecten

The Netherlands

0 Likes
Message 6 of 6

autodesk
Explorer
Explorer

Hello, if you need to find the name of the downloaded assembler code file, you can use this code:

 

public static string GetAssemblyCodeTableFilePath(Document doc)
{
ExternalResourceType refType = new ExternalResourceType(new Guid ("cf823dbb-21d2-42e0-a39c-1cb523a8cec2"));
ExternalResourceReference externalResource = AssemblyCodeTable.GetAssemblyCodeTable(doc).GetExternalResourceReference(refType);
if (externalResource != null)
{
return externalResource.InSessionPath;
}
else
{
return null;
}
}