# Python - Cant get View Family Types Name in one script

**URL:** <https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771>\
**Category:** Developers\
**Tags:** revit\
**Created:** [June 29, 2016, 7:48am UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771 "2016-06-29T07:48:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Bell](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@Kevin\_Bell](https://forum.dynamobim.com/u/Kevin_Bell)\
**Post date:** [June 29, 2016, 7:48am UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771/1 "2016-06-29T07:48:57Z")

</div>

Hi,

I’m writing some Python code in Dynamo to set up elevations.

As part of this I need to find a certain ViewFamilyTypes - to do this I need to return the ViewFamilyTypes Name, which I can do with the following two pieces of code:

(Note that the code picks out the fifth ViewFamilyTypes - which is the one I need, I will eventually write some code which evaluates the list).

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/7/78f87486b69b25b54f09bf85875670045eb8bcbd.png)

And then:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/0/0bbdbb25a72bc430f4b931200e948f664a564c60.png)

This returns:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/9/9e0d75e1f8dd9aa0c0759a9b27fb7f72fbf924fc.png)

Which is what I want.

But I want don’t want two pieces of code, I want to add them together, so I did this:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/8/8a8e4cf0024e82aa89be9fae876f7657aa39d843.png)

But this generates the error:

![](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/4/46427789c080775ce7cd637f1b562f617c0afca0.png)

Am I missing something, I cant work out why two pieces of code works, whereas one doesn’t.

I would appreciate some advise.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [June 29, 2016, 1:06pm UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771/2 "2016-06-29T13:06:35Z")

</div>

Hi @Kevin_Bell

If you wrap your element you’ll be able to access it’s name :

 ![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/5/553582e3d4b637ad34b90bf61f11abccea3fcb80.JPG)

Make sure to import all the required extensions:

```
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

doc = DocumentManager.Instance.CurrentDBDocument
a = []

viewfamilies = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()

pickone = viewfamilies[5].ToDSType(True)

name = pickone.Name

OUT = name
```

---

<div class="post-metadata">

**Author:** ![Kevin\_Bell](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@Kevin\_Bell](https://forum.dynamobim.com/u/Kevin_Bell)\
**Post date:** [July 1, 2016, 2:34pm UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771/3 "2016-07-01T14:34:36Z")

</div>

I see, I thought wrapping was either the WrapElements or UnWrapElements command - ToDSType is new to me.

Where can I find information about the Revit.Elements namespace? Looking through the Revit 2015 API.chm help file I cannot seem to find anything in there. Guess its a Dynamo thing then…

---

<div class="post-metadata">

**Author:** ![Einar\_Raknes](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/einar_raknes/32/8566_2.png) [@Einar\_Raknes](https://forum.dynamobim.com/u/Einar_Raknes)\
**Post date:** [July 1, 2016, 3:03pm UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771/4 "2016-07-01T15:03:09Z")

</div>

Yes It’s a Dynamo thing. You can read about it here: [https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#revitapi](https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#revitapi) (and maybe here [http://dynamoprimer.com/09\_Custom-Nodes/9-5\_Python-Revit.html](http://dynamoprimer.com/09_Custom-Nodes/9-5_Python-Revit.html))

---

<div class="post-metadata">

**Author:** ![ali.safiaddine](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ali.safiaddine/32/17048_2.png) [@ali.safiaddine](https://forum.dynamobim.com/u/ali.safiaddine)\
**Post date:** [May 3, 2019, 5:44pm UTC](https://forum.dynamobim.com/t/python-cant-get-view-family-types-name-in-one-script/4771/5 "2019-05-03T17:44:14Z")

</div>

Thank you @Mostafa_El_Ayoubi this is helpful. But I was wondering if want to get the name of a ViewFamily in a python script but outside dynamo will this work?  
Since I far as I know that unwrapping Elements is only a dynamo thing right?
