Get ElementID by passing in View Name

Hi I want to get the ElementID by passing in VIew Name from sections.
I want to set “Far Clip Offset” to room bounding walls, dont know how to do that witout extracting the ElementID by the View Name.

Trying to make a Python-script but dosent seem to work.

Error: Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 25, in
File “”, line 19, in get_ElementIds_from_name
TypeError: list is not callable

import clr
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument



def get_ElementIds_from_name(Name):
    rule = ParameterFilterRuleFactory.CreateEqualsRule(Name(BuiltInParameter.VIEW_NAME), Name, True)
    filt = ElementParameterFilter(rule)
    return FilteredElementCollector(doc).WherePasses(filt).WhereElementIsNotElementType().ToElementIds()

test = "1123 Sandfilter - Vy 2"

OUT = [get_ElementIds_from_name(Name) for Name in IN[0]] 


Hello your IN[0] is not defined

Cordially
christian.stan

Hi Christian.

Shouldent this be enough or shall I define it higher up?

OUT = [get_ElementIds_from_name(Name) for Name in IN[0]] 

My Companys IT dont let me install Visual Studio Code so its sometimes hard to solve different tasks.

I think you’re right (not necessarily need to have IN[0] before), I try to help up to my skills
if you add
OUT = [get_ElementIds_from_name(Name) for Name if Name==test in IN[0]]

Cordially
christian.stan

I’m thankfull for your effort, keep it up.

1 Like

I don’t think that solves your issue, it’s more of a data structure issue. You will need to first flatten your list(s) to a single list, then get a unique item from the list, then pass through your code if what you want is to get all items from a single matched parameter value

1 Like