Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Get family types

Yonas89
Collaborator

Get family types

Yonas89
Collaborator
Collaborator

Hello,

 I'm  trying to get family types available in the document. It looks, that I've found a simple example how to deal with family types here: 

public void GetFamilyTypesInFamily(Document familyDoc)
{
    if (familyDoc.IsFamilyDocument)
    {
        FamilyManager familyManager = familyDoc.FamilyManager;

        // get types in family
        string types = "Family Types: ";
        FamilyTypeSet familyTypes = familyManager.Types;
        FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
        familyTypesItor.Reset();
        while (familyTypesItor.MoveNext())
        {
            FamilyType familyType = familyTypesItor.Current as FamilyType;
            types += "\n" + familyType.Name;
        }
        TaskDialog.Show("Revit",types);
    }
}

 

However, after I run this function I get this :

issue.PNGThough I'm quite new to Revit and it's API, as I understand I have at least 2 family types (pp1 and pp2), so why I do not get them?

Reply
Accepted solutions (1)
10,719 Views
11 Replies
Replies (11)

jeremytammik
Autodesk
Autodesk

The code you show is designed to work within the family definition in an RFA file.

 

The project browser snapshot you show is in a project, an RVT file.

 

That requires a different approach. 

 

Here is one way to go to export a family usage report in a project to XML:

 

http://thebuildingcoder.typepad.com/blog/2010/12/xml-family-usage-report.html

 

Cheers,

 

Jeremy

 

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Yonas89
Collaborator
Collaborator

Thanks a lot for your reply Jeremy,

 

However I cannot fully agree with you here. It's a RFA file I am working in. Also there is a condition in third line:  "if (familyDoc.IsFamilyDocument) "  and TaskDialog only shows under this condition, thus this lets me to believe that its an RFA file type. 

0 Likes

jeremytammik
Autodesk
Autodesk

Oh dear. I think you are absolutely right, and I was completely wrong. Sorry about that.

 

My next suggestion would be to have a look at your RFA file database contents using RevitLookup.

 

Have you done that yet?



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

so-chong
Advocate
Advocate

Hi,

In general family types of an element are stored in different places (depending on which categories) in the project browser in a project document (rvt).
In a family document (rfa), that's different organized.
You will find family types in the modify tab (properties panel; with the four blue cubes icon) in a family document.

family-types-button.png

So your screenshot saying about 'family' type pp1 and pp2, those are not your family types.

Your are referring to something like 'profile' types, do you? That is something different.
By the way, there is nothing wrong with your sample code.
Test it on a different family document, then you will get the family types.

 

Good luck!

so-chong

Yonas89
Collaborator
Collaborator

Hello @so-chong,

indeed you are absolutely right.  However, how should I retrieve these profiles? For instance in Dynamo, it's listed under family types ( image below), but in c# as we proved it's a bit different.       Capture.PNG

 

 

 

 

0 Likes

so-chong
Advocate
Advocate

Hi Yonas,

Hmm..interesting how Dynamo place these profiles in 'Family Types'.

Family Types must have a different meaning in Dynamo then in Revit.

I have no experience with Dynamo at all.

Could you provide  a family document (rfa) where these profiles exist?

As an attachment in your message.

0 Likes

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

First i suggest to get a Revit lookup, this way you can see what class and what parameters have object you selected, it make life easier.
Going back to your problem, it look like you what to find FamilySymbol(that's how family types class is called in Project document).

I can only speculate but it look like you create new types in project, but then open a family in Api from path(new made types in project are not saved to family) and search for it. Remember that if you didn't name your type in family editor it will be named by family name, but from api it will be empty string.

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Yonas89
Collaborator
Collaborator

@so-chong,

please find an attached family file.

0 Likes

Yonas89
Collaborator
Collaborator

@MarryTookMyCoffeand @jeremytammik,

thanks a lot for your advice about Revit look up. @MarryTookMyCoffe, you were right. It's familysymbol type. Now I am able to get these types.

mary.gurrieri
Community Visitor
Community Visitor

Can you please send final product I need to use this code? @Yonas89 

 

0 Likes

choshQT24J
Enthusiast
Enthusiast

Sorry, is there any code? I think I have the same problem.

0 Likes