get FamilySymbol from Family Class

get FamilySymbol from Family Class

Anonymous
Not applicable
2,913 Views
4 Replies
Message 1 of 5

get FamilySymbol from Family Class

Anonymous
Not applicable

I am new to revit API development. 

I want to get Family Symbol from Family. while I was checking in revit API Documentation I found below code

public void GetInfoForSymbols(Family family)
{
    StringBuilder message = new StringBuilder("Selected element's family name is : " + family.Name);
    ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();  //ERROR

    if (familySymbolIds.Count == 0)
    {
        message.AppendLine("Contains no family symbols.");
    }
    else
    {
        message.AppendLine("The family symbols contained in this family are : ");

        // Get family symbols which is contained in this family
        foreach (ElementId id in familySymbolIds)
        {
            FamilySymbol familySymbol = family.Document.GetElement(id) as FamilySymbol;
            // Get family symbol name
            message.AppendLine("\nName: " + familySymbol.Name);
            foreach (ElementId materialId in familySymbol.GetMaterialIds(false))
            {
                Material material = familySymbol.Document.GetElement(materialId) as Material;
                message.AppendLine("\nMaterial : " + material.Name);
            }
        }
    }

    TaskDialog.Show("Revit",message.ToString());
}

 I am getting an error in ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();

ISet is not defined. Can anybody help me in retrieving symbols from family.

0 Likes
Accepted solutions (1)
2,914 Views
4 Replies
Replies (4)
Message 2 of 5

Revitalizer
Advisor
Advisor

Hi,

 

add

 

using System.Collections.Generic;

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 5

Anonymous
Not applicable

I am using generic class "using System.Collections.Generic;" but Still its giving error

 

The Suggestion I am getting is:

 

class Autodesk.Revit.DB.ElementId

The ElementId object id used as a unique identification for an element within a single project.

The type or namespace name 'ISet<>' could not be found(are missing directive or an assembly reference?)

 

 

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

Got the solution. I was using an older .net framework that's why the error was coming.

Thanks @Revitalizer

0 Likes
Message 5 of 5

Revitalizer
Advisor
Advisor

Hi,

 

yes, these problems - caused by false framework - are not obvious.

 

Congrats for solving it.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes