Hi All,
I’m encountering an issue reading the Rebar type names from the collected Rebar types and selecting the one I’m looking for. I tried accessing the Name
property using two different syntaxes: RebarType.Name
or Element.Name.GetValue(RebarType)
, but neither works. I’m getting the following errors according the used syntax:
I also tried collecting rebar types by their Ids
and then getting the elements, but I still get the same errors
Otherwise, either syntax works correctly in the Revit Python Shell as shown below
Here the two codes:
Syntax: RebarType.Name
import clr
import sys
import System
import math
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import specify namespace
#import net library
from System import Array
from System.Collections.Generic import List, IList, Dictionary
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# select all rebar types within the project
rebar_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsElementType().ToElements()
rebar = [r for r in rebar_Types if r.Name == "HA12 (Fe400)"]
OUT = rebar
Syntax : Element.Name.GetValue(RebarType)
import clr
import sys
import System
import math
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
#import specify namespace
#import net library
from System import Array
from System.Collections.Generic import List, IList, Dictionary
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# select all rebar types within the project
rebar_Types = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rebar).WhereElementIsElementType().ToElements()
rebar = [r for r in rebar_Types if Element.Name.GetValue(r) == "HA12 (Fe400)"]
OUT = rebar
Note: I’m using Revit 2023
Any help would be appreciated.
Thanks.