How to get OmniClass Number

How to get OmniClass Number

chuong_do77UDA
Observer Observer
1,314 Views
5 Replies
Message 1 of 6

How to get OmniClass Number

chuong_do77UDA
Observer
Observer

hi there,

Do we have any way to get the OmniClass Number in the Identity Data by using API?

For example : I have Engine Generators has OmniClass Number = "23.80.10.11.11.11". How can I get this value?

Thanks.

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

architect.bim
Collaborator
Collaborator

Hi! Omniclass Number is a System Type Parameter. To get it for each element first you need to get Element's Type and then try to get the OMNICLASS_CODE parameter. If this particulat ElementType has it, then you can get its value. Here is the sample code:

foreach (Element element in elements)
{
    ElementType elementType = doc.GetElement(element.GetTypeId()) as ElementType;
    Parameter omniClassNumber = elementType.get_Parameter(BuiltInParameter.OMNICLASS_CODE);
    if (omniClassNumber != null)
    {
        string value = omniClassNumber.AsString();
        if (!string.IsNullOrEmpty(value))
        {
            Console.WriteLine(value);
        }
        else
        {
            Console.WriteLine("No Value");
        }
    }
    else
    {
        Console.WriteLine("Element does not have Omni Class Number Parameter");
    }
}

 


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 3 of 6

chuong_do77UDA
Observer
Observer

Thanks for your answer. Base on your code it only gets OmniClass Number = "23.80.10.11" ( Electrical Generators)

 

It should be "23.80.10.11.11.11" of Engine Generators. Please review again and help. Thank you.

OmniClassNumber.png

0 Likes
Message 4 of 6

architect.bim
Collaborator
Collaborator

Hi! There is no problem to get Omni Class Number of any kind using the code I've provided you above. I've tested this code in Python and it works fine too.

architectbim_0-1683764705998.jpeg

Actually there is nothin to review, just simply use it 😃

If you don't see the last digits of the omniclass, they may simply not be printed. Or you may have made an inaccuracy somewhere. Either way, there is actually no other way to get this number. It is stored as a string parameter value. And to get it, you need the methods I mentioned above.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 5 of 6

chuong_do77UDA
Observer
Observer

hi there,

I am using FilteredElementCollector to filter elements.

 

filter = new BuiltInCategory[] {
BuiltInCategory.OST_ElectricalEquipment,
BuiltInCategory.OST_ElectricalFixtures,
BuiltInCategory.OST_LightingDevices,
BuiltInCategory.OST_LightingFixtures,
BuiltInCategory.OST_Wire, 
BuiltInCategory.OST_ElectricalCircuit,
BuiltInCategory.OST_WireMaterials,
BuiltInCategory.OST_WireInsulations,
BuiltInCategory.OST_WireTemperatureRatings,
BuiltInCategory.OST_ElecDistributionSys,
BuiltInCategory.OST_ElectricalVoltage,
BuiltInCategory.OST_MechanicalEquipment,
BuiltInCategory.OST_Levels,
};

Do you think the filter I miss anything?

0 Likes
Message 6 of 6

architect.bim
Collaborator
Collaborator
Accepted solution

I'm not sure how this question relates to the omniclass number. I would advise you to accept solution for this question and create a new query in the forum if you have any new questions.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes