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: 

How to get FamilyType out of FamilySymbol?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
raunoveb
2245 Views, 4 Replies

How to get FamilyType out of FamilySymbol?

Hello!

 

I am somewhat confused about how exactly do these FamilyTypes and FamilySymbols work. For example: 

1. We store our Family files on a DMS system so that all the families would be accessible for everyone in our company.

2. To link a family file to a DMS info record we created some Shared Parameters and added them to our families + then we set these paremeters on our Families and their Types.

3. Every once in a while an engineer, designer or architect creates a new Family and some Types to go with it

4. Now we need to check our project model if it contains any of those new families that don't have DMS parameters set

5. We created a code snippet that picked up all the visible FamilyInstances on the model

6. One-by-one we iterate through these instance and get a FamilySymbol out of it

7. Now arises the need to change the shared parameters of this symbol but that seems to be nigh impossible. However we have a workaround (Not completely trustworthy in my opinion) for that.

8. From FamilySymbol we get Family, then FamilyDocument, then FamilyManager that has Property called Types. Finally we iterate through these types and try to match one of them to the FamilySymbol we got previously. We are doing that using .Name property on both FamilyType and FamilySymbol.

9. There are rare cases when a Family contains only one Type and when that happens FamilyType.Name seems to be empty however FamilySymbol.Name returns Family.Name. We can't match FamilySymbol to FamilyType when that is the case.

 

Now that our problem is somewhat explained I'd like to ask - is there any way to convert a FamilySymbol into FamilyType without 20+ lines of code?

If there is could somebody please explain the difference between FamilyType and FamilySymbol classes?

4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: raunoveb

Dear Raunoveb,

 

Please excuse me for answering your question without reading the full text of your query.

 

This is just an initial stab at an answer.

 

I hope it resolves all your questions anyway:

 

The family type and the family symbol are exactly the same thing.

 

The term type is used more in the family context, and the term symbol more in the project, but basically they are the same.

 

For instance, the FamilyInstance.Symbol property returns a FamilySymbol instance which represents the family type.

 

I say this, because I was also confused when initially starting to work with the Revit API.

 

It helps to understand this from a product point of view before delving into the API side of things.

 

Dear others, please correct me if I am wrong or you do not agree with my wording.

 

Thank you!

 

Best regards,

 

Jeremy



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

Message 3 of 5
raunoveb
in reply to: jeremytammik

I figured as much. What still bothers me is that Revit API developers guide says nothing about this. Thanks for the feedback though. Now i need to refactor all the code where I used FamilyManager.Types foreach iteration just to get that single type that had the same name that my symbol had 🙂

 

However in OO coding they usually leave a Property/converter method that allows conversion of similar/same type of objects.

Message 4 of 5

Hi,

 

I found this this old thread because I have the following error in my code:

 

"It is not possible to implicitly convert Autodesk.db.FamilyType into Autodesk.db.FamilySymbol"

 

I tried (FamilySymbol)SampleFamilyType with no luck...

 

So  even if both entities represent the same element in Revit (a Family type) there is a conversion required to transform one entity into the other. How can I convert between them? 

 

For info, I am retrieving the familySimbols  from a family loaded into the project, and I am adding new ones using the family manager (using .NewType method).

 

Message 5 of 5

Hi again,

 

I found a much clearer explantion of the difference between both type of ojects in your blog, Jérémy. Now it is clear why not direct conversion exists between FamilyTypes and FamilySymbols (but we can match them by their respective names)

 

https://thebuildingcoder.typepad.com/blog/2013/01/family-symbols-versus-types.html

 

 

Regards,

 

Juan

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community