ODS module does not work on IronPython, and i don’t know the way to add Revit modules to regular Python.Whatever …
''' cut-n-paste from the net
@author: ejs
'''
import clr
import sys
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Analysis import *
#sys.path.append(r'C:\Python\3.4\Lib\site-packages')
#from odslib import ODS
#ods = ODS()
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
cView = uidoc.ActiveView
collector = FilteredElementCollector(doc)
collector = FilteredElementCollector(doc).OfClass(ViewSchedule);
elems=collector.ToElements()
n_elems=len(elems)
for elem in elems:
if cView.Id == elem.Id:
cSch = doc.GetElement(elem.Id)
print "\t Schedule ID: ", cSch.Id, ", schedule name: '", cSch.Name, "'"
cSchCol = FilteredElementCollector(doc, cSch.Id).ToElements();
# sheet title
# sheet = ods.content.getSheet(0)
# sheet.setSheetName(cSch.Name)
cSheetRow=0
for cElem in cSchCol:
#print cElem
print "\t\t Element ID:", cElem.Id, ", Name:", cElem.Name
cSheetColumn=0
for cParam in cElem.Parameters:
cPValue = cParam.AsValueString()
if cPValue is None:
cPValue = ""
print "Current sheet cell [", cSheetRow, cSheetColumn, "]"
print "\t\t\t", cParam.Definition.Name, ":", cPValue
if cSheetRow == 0:
# headings
#sheet.getCell(cSheetRow, cSheetColumn).stringValue(cParam.Definition.Name).setFontSize('14pt')
#sheet.getCell(cSheetRow+1, cSheetColumn).stringValue(cPValue)
#sheet.getRow(cSheetRow).setHeight('18pt')
cSheetColumn = 0
cSheetRow=2
else :
#sheet.getCell(cSheetRow, cSheetColumn).stringValue(cPValue)
cSheetColumn = cSheetColumn + 1
cSheetRow = cSheetRow + 1
#ods.save([doc.Title, ".ods"])
And the output is …
Schedule ID: 239886 , schedule name: ' Door Schedule ' Element ID: 239788 , Name: 910 x 2110mm Current sheet cell [ 0 0 ] Finish : Current sheet cell [ 2 0 ] Phase Created : Current sheet cell [ 2 1 ] Sill Height : 0.0 Current sheet cell [ 2 2 ] Frame Type : Current sheet cell [ 2 3 ] Comments : Current sheet cell [ 2 4 ] Head Height : 2110.0 Current sheet cell [ 2 5 ] Level : Current sheet cell [ 2 6 ] Frame Material : Current sheet cell [ 2 7 ] Mark : Current sheet cell [ 2 8 ] Phase Demolished : Element ID: 239807 , Name: 1010 x 2110mm Current sheet cell [ 3 0 ] Finish : Current sheet cell [ 3 1 ] Head Height : 2110.0 Current sheet cell [ 3 2 ] Frame Material : Current sheet cell [ 3 3 ] Mark : Current sheet cell [ 3 4 ] Level : Current sheet cell [ 3 5 ] Comments : Current sheet cell [ 3 6 ] Phase Demolished : Current sheet cell [ 3 7 ] Sill Height : 0.0 Current sheet cell [ 3 8 ] Frame Type : Current sheet cell [ 3 9 ] Phase Created : Element ID: 239826 , Name: 1010 x 2110mm Current sheet cell [ 4 0 ] Phase Created : Current sheet cell [ 4 1 ] Sill Height : 0.0 Current sheet cell [ 4 2 ] Comments : Current sheet cell [ 4 3 ] Frame Material : Current sheet cell [ 4 4 ] Head Height : 2110.0 Current sheet cell [ 4 5 ] Mark : Current sheet cell [ 4 6 ] Phase Demolished : Current sheet cell [ 4 7 ] Level : Current sheet cell [ 4 8 ] Finish : Current sheet cell [ 4 9 ] Frame Type : Element ID: 239844 , Name: 910 x 2110mm Current sheet cell [ 5 0 ] Phase Demolished : Current sheet cell [ 5 1 ] Mark : Current sheet cell [ 5 2 ] Frame Material : Current sheet cell [ 5 3 ] Finish : Current sheet cell [ 5 4 ] Comments : Current sheet cell [ 5 5 ] Sill Height : 0.0 Current sheet cell [ 5 6 ] Phase Created : Current sheet cell [ 5 7 ] Frame Type : Current sheet cell [ 5 8 ] Head Height : 2110.0 Current sheet cell [ 5 9 ] Level : Element ID: 239866 , Name: 910 x 2110mm Current sheet cell [ 6 0 ] Sill Height : 0.0 Current sheet cell [ 6 1 ] Frame Type : Current sheet cell [ 6 2 ] Frame Material : Current sheet cell [ 6 3 ] Head Height : 2110.0 Current sheet cell [ 6 4 ] Phase Created : Current sheet cell [ 6 5 ] Comments : Current sheet cell [ 6 6 ] Finish : Current sheet cell [ 6 7 ] Phase Demolished : Current sheet cell [ 6 8 ] Level : Current sheet cell [ 6 9 ] Mark :