Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get family types

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Yonas89
9844 Views, 11 Replies

Get family types

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?

11 REPLIES 11
Message 2 of 12
jeremytammik
in reply to: Yonas89

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

Message 3 of 12
Yonas89
in reply to: jeremytammik

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. 

Message 4 of 12
jeremytammik
in reply to: Yonas89

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

Message 5 of 12
so-chong
in reply to: Yonas89

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

Message 6 of 12
Yonas89
in reply to: so-chong

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

 

 

 

 

Message 7 of 12
so-chong
in reply to: Yonas89

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.

Message 8 of 12
MarryTookMyCoffe
in reply to: Yonas89

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
Message 9 of 12
Yonas89
in reply to: so-chong

@so-chong,

please find an attached family file.

Message 10 of 12
Yonas89
in reply to: MarryTookMyCoffe

@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.

Message 11 of 12
mary.gurrieri
in reply to: Yonas89

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

 

Message 12 of 12
choshQT24J
in reply to: Yonas89

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community