clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
from Autodesk.Revit.DB.Events import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Structure import *
from Autodesk.Revit.DB.Mechanical import *
from Autodesk.Revit.DB.Electrical import *
from Autodesk.Revit.DB.Plumbing import *
Hi Daniel, here is a simplified version of your code which achieves essentially the same result:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Collect all Lighting Fixtures in current document
elements = FilteredElementCollector(doc)\
.OfCategory(BuiltInCategory.OST_LightingFixtures)\
.WhereElementIsNotElementType()
# Access ElementId (Id property) of each Element
ids = [e.Id for e in elements]
# Get 'Mark' Parameter for each Element
parameters = [e.LookupParameter('Mark') for e in elements]
OUT = elements, ids, parameters
Most of the imported libraries and namespaces aren’t being referenced (ProtoGeometry, Events, Mechanical, Electrical, Plumbing), so I’ve removed them in order to show only what is necessary. Currently, only elements from the Lighting Fixtures category are being collected, but this can be changed by replacing BuiltInCategory.OST_LightingFixtures with another member of the BuiltInCategory Enumeration, e.g. OST_ElectricalEquipment.
Currently, this script only outputs the actual Parameter object, so you will need to use the appropriate method (AsString(), AsValueString(), AsElementId(), AsInteger(), AsDouble()) to get its value. The proper method can typically be determined by looking at the Parameter’s StorageType property.
Hi, yesterday i search some help for REVIT Python and Dynamo.
I have install IronPython, very goog API to debug Python, with rps_init.py from gtalarico i can easely
list all methods usable.
And RevitLookup i can now be sure that all my syntax are correct.
The correct line code is: type_names = [e.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString for e in elements]
Daniel OLIVES
Hi Daniel, rather than using a blockquote, you can use the “preformatted text” option so that your code appears correctly:
#Import libraries
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import * #FilteredElementCollector, BuiltInCategory
clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Collect all Lighting Fixtures in current document
elements = FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_LightingFixtures)
.WhereElementIsNotElementType()
# Access Element Type(Id property) of each Element Family Type: and Family: and Id
#only for test
stype = [e.Document.GetElement(e.GetTypeId()) for e in elements]
# Access Element type name = ‘600x600 - 277’
Type_NameL =
for e in elements:
Type_Name = e.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString()
Type_NameL.append(Type_Name)
# Access Element Family name = ‘M_Pendant Light - Linear - 2 Lamp’
Family_NameL = [e.LookupParameter(‘Famille’).AsValueString() for e in elements]
# Access Element Name (Name property) of each Element
name = [e.Name for e in elements]
# Access Element Id (Id property) of each Element
ids = [e.Id for e in elements]
# Access Element parameters ‘Commentaires’
parameters = [e.LookupParameter(‘Commentaires’).AsString() for e in elements]
OUT = Family_NameL, Type_NameL, name, ids, parameters