# Get All Sections

**URL:** <https://forum.dynamobim.com/t/get-all-sections/85147>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [January 19, 2023, 12:29pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147 "2023-01-19T12:29:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagadeesh116](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jagadeesh116/32/156748_2.png) [@jagadeesh116](https://forum.dynamobim.com/u/jagadeesh116)\
**Post date:** [January 19, 2023, 12:29pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/1 "2023-01-19T12:29:02Z")

</div>

Hi All,

I have been trying to collect all sections in a project. I am using python Filtered Element Collector and of class(ViewSection). I am able to collect all view sections which include callouts, elevations, axonometric views and sections. I have been facing an error as  
\*\*"Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. \*\*  
**unexpected token ‘=’".**  
Below snaps are sample images and code.

 ![01.Get All View Types](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/8/78ea57753dae2b9f6b4d99fe812dd0dc4ee58dbc.jpeg)

**Method 1:**

**import** clr  
clr. **AddReference** (‘RevitAPI’)  
**import** Autodesk  
**from** Autodesk.Revit.DB **import** \*  
clr. **AddReference** (‘RevitServices’)  
**import** RevitServices  
**from** RevitServices.Persistence **import** DocumentManager  
doc = DocumentManager.Instance.CurrentDBDocument  
ViewSections = **FilteredElementCollector** (doc). **OfClass** (ViewSection). **ToElements** ()  
vs\_str = []  
**for** v **in** ViewSections:  
**if** v.ViewType.ToString = “Section”  
vs\_str. **append** (v)  
OUT = vs\_str

**Method 2:**

**import** clr  
clr. **AddReference** (‘RevitAPI’)  
**import** Autodesk  
**from** Autodesk.Revit.DB **import** \*  
clr. **AddReference** (‘RevitServices’)  
**import** RevitServices  
**from** RevitServices.Persistence **import** DocumentManager  
doc = DocumentManager.Instance.CurrentDBDocument  
ViewSections = **FilteredElementCollector** (doc). **OfClass** (ViewSection). **ToElements** ()  
vs\_str = []  
**for** v **in** ViewSections:  
**if** v.ViewType = Section  
vs\_str. **append** (v)

OUT = vs\_str

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [January 19, 2023, 12:43pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/2 "2023-01-19T12:43:56Z")

</div>

@jagadeesh116 ,

i come to here

```auto
import System
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

from System.Collections.Generic import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Views)
sections = collector.WhereElementIsNotElementType().ToElements()

OUT = sections

```

---

<div class="post-metadata">

**Author:** ![jagadeesh116](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jagadeesh116/32/156748_2.png) [@jagadeesh116](https://forum.dynamobim.com/u/jagadeesh116)\
**Post date:** [January 19, 2023, 1:00pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/3 "2023-01-19T13:00:41Z")

</div>

Hi Draxl,

the above script gives null out put .if we use another line as  
views =   
for v in sections:  
views.append(v.Name)

gives view names which include floor plans,celing plan and sections.I am trying to seperate sections.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [January 19, 2023, 2:58pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/4 "2023-01-19T14:58:53Z")

</div>

@jagadeesh116 ,

thats realy weard… i can`t get it.  
[sections.dyn](https://forum.dynamobim.com/uploads/short-url/iF2dfiiYaKPbGXfhVJKoUvPmxdE.dyn) (11.9 KB)

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/f/2f6d12da73ac3623ae72234e7b3dcb3f505f4e91.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 19, 2023, 3:56pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/5 "2023-01-19T15:56:11Z")

</div>

> [@jagadeesh116](#):
>
> **if** v.ViewType.ToString = “Section”

This is what’s causing your problem. A single = means “to set equal to”. A double == means “is equal to”. The former changes a value and the latter checks a value.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [January 19, 2023, 4:30pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/6 "2023-01-19T16:30:58Z")

</div>

@Nick_Boyts ,

![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/e/7e8863b7e802727205d144be1665f8a5549b90e8.png)

i got this warning …

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 19, 2023, 4:42pm UTC](https://forum.dynamobim.com/t/get-all-sections/85147/7 "2023-01-19T16:42:20Z")

</div>

You’re not iterating through your list. You’re trying to get the `ViewType` from the list instead of the view right now.

---

<div class="post-metadata">

**Author:** ![jagadeesh116](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jagadeesh116/32/156748_2.png) [@jagadeesh116](https://forum.dynamobim.com/u/jagadeesh116)\
**Post date:** [January 21, 2023, 6:07am UTC](https://forum.dynamobim.com/t/get-all-sections/85147/8 "2023-01-21T06:07:03Z")

</div>

Hi Nick,  
Thanks for ur response.  
Actually there is typing mistake i have given ==(“=” means assign values,"==’ means equals).  
As per ur next reply i have understood and tried:

# get sectionlines in active view

Views = FilteredElementCollector(doc).OfClass(View).ToElements()

# get viewname parameter

ViewT =   
for v in Views:  
if v.ViewType.ToString() == “Section”:  
ViewT.append(v.Name)

OUT = ViewT

I got the result thanks

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/b/9b5b9591aa0d38391243318d16afdcf8eaf0eaf6.jpeg)
