Is Same between .OfClass(typeof(FamilySymbol)) and .WhereElementIsElementType() ?

Is Same between .OfClass(typeof(FamilySymbol)) and .WhereElementIsElementType() ?

XARMA
Advocate Advocate
261 Views
3 Replies
Message 1 of 4

Is Same between .OfClass(typeof(FamilySymbol)) and .WhereElementIsElementType() ?

XARMA
Advocate
Advocate

I think 

.OfClass(typeof(FamilySymbol))

return familyType and

.WhereElementIsElementType()

return familyType also. but then Why are they exist both?

0 Likes
Accepted solutions (1)
262 Views
3 Replies
Replies (3)
Message 2 of 4

Mohamed_Arshad
Advisor
Advisor
Accepted solution

Hi @XARMA 

You have a slight misunderstanding on this. As you mentioned, FamilySymbol returns a FamilyType. However, in Revit, some elements don't have a definite type and instead fall under the general Element category. For example, a 3DSectionBox has no specific type—it is classified under Element. These kinds of elements are filtered using the WhereElementIsElementType() method.

 

Mohamed_Arshad_0-1745576115641.png


Hope this will Helps šŸ™‚

Thanks & Regards,
Mohamed Arshad K
0 Likes
Message 3 of 4

TripleM-Dev.net
Advisor
Advisor

@Mohamed_Arshad, are you sure.

I never assumed that, always assumed it returns all elements derived from ElementType (like documentation states: https://revapidocs.com/2020.htm?id=77793daa-5a26-b4d6-9019-4d998a55099e.htm )

 

@XARMA 

.OfClass(typeof(FamilySymbol)) returns FamilySymbol elements, which is derived from ElementType

 

.WhereElementIsElementType() will return ElementType's, some may be FamilySymbol but doesn't have to be.

 

For instance take a Door familytype and a Wall type.

.OfClass(typeof(FamilySymbol)) will only return the Door familytype as it's derived from FamilySymbol and WallType isn't

.WhereElementIsElementType() will return both door and wall type because both are derived from ElementType

 

So depending what's you need UserFamily Type or all types will determine which to use.

 

- Michel

 

Ps Use RevitLookup addin to inspect how different elements are build.

Message 4 of 4

Mohamed_Arshad
Advisor
Advisor

Hi @TripleM-Dev.net 

 

Thank you for your clarification :). I miss understood the concept of WhereElementIsElementType(), It is returning the base class (Type).

Thanks & Regards,
Mohamed Arshad K
0 Likes