Get All Sections

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.

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

@jagadeesh116 ,

i come to here

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

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.

@jagadeesh116 ,

thats realy weard… i can`t get it.
sections.dyn (11.9 KB)

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.

2 Likes

@Nick_Boyts ,

grafik

i got this warning …

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

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

1 Like