- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Yes, I've searched the forums!
Yes, I've searched Jeremy's amazing resources!
Yes, I use Revit Lookup!
Yes, to probably everything else, so I admit I need help after a three day frustration journey!
Okay, being funny, but I wanted that out of the way.
I have a Python Script that gets All families in a model, adds the Family Name, Type Name, and a Shared Parameter value to separate lists.
The ONE thing that I cannot seem to resolve is how to get this information from Revit Lookup (when I look at a typical family in the model):
Current Selection/MEPmodel/ConnectorManager/Connectors/ElectricalSystemType
In my code I tried bringing over some C# that I gathered from Jeremy and another post. So I left it in there even though it doesn't work and maybe someone can point me in the right direction.
Here's my entire Python Code:
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
app = doc.Application
import sys
import clr
clr.AddReference("RevitAPIUI")
import time
if doc.IsFamilyDocument == True:
__window__.Close()
TaskDialog.Show("Wrong Document Type", "This script is for getting information on Load Classifications in a project, it cannot be run in a family.")
sys.exit()
start = time.time()
allFamilyTypes = []
containsLoadClass = []
LoadClassList = []
def runit():
Elements = FilteredElementCollector(doc).OfClass(Family)
for m in Elements:
famCnt = 1
try:
symbols = list(m.GetFamilySymbolIds())
allFamilyTypes.append("\n" + m.Name)
for i in symbols:
#Get symbols from family
famsymbol = doc.GetElement(i)
symbolName = famsymbol.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()
allFamilyTypes.append(" Type = " + symbolName)
try:
#Retrieve Shared Parameter Load Classification if it exists
loadclass = famsymbol.LookupParameter("Load Classification")
loadClassStr = loadclass.AsValueString()
if famCnt == 1:
containsLoadClass.append("\n" + m.Name)
famCnt += 1
containsLoadClass.append(" Type = " + symbolName)
containsLoadClass.append(" Load Classification = " + loadClassStr)
LoadClassList.append(loadClassStr)
except:
pass
try:
#Here I want to get ElectricalSystemType from a connector if it exists
#Revit Lookup - Current Selection/MEPModel/ConnectorManager/Connectors/ElectricalSystemType
it = famsymbol.MEPModel.ConnectorManager.Connectors.GetEnumerator()
it.MoveNext()
conn = it.Current
famConnInfo = conn.GetMEPConnectorInfo()
param = famConnInfo.GetConnectorParameterValue(ElectricalSystemType)
print param
except:
pass
except:
pass
print "Gathering family information."
runit()
print "\nEnter 1 for ALL Families and Types"
print "Enter 2 for Families and Types containing Load Classification"
print "Enter 3 to list Load Classifications used in Project"
userinput = raw_input("\nEnter Number: ")
if int(userinput) == 1:
#List all Families and Types
for m in allFamilyTypes:
print m
elif int(userinput) == 2:
#List all Families and Types with Load Classification
print "\nList of Families and Types with Load Classification defined:\n"
for m in containsLoadClass:
print m
elif int(userinput) == 3:
#List ONLY the Load Classifications being used in a Project
LoadClassNames = list(dict.fromkeys(LoadClassList))
totalLC = 0
totalLC = len(LoadClassNames)
print "\nThere are " + str(totalLC) + " Load Classifications in Project:\n"
cnt = 1
for m in LoadClassNames:
print " " + str(cnt) +") " + m
cnt += 1
else:
print "That was not a choice!"
end = time.time()
hours, rem = divmod(end-start, 3600)
minutes, seconds = divmod(rem, 60)
TotalTime = ("{:0>2}:{:0>2}:{:05.2f}".format(int(hours),int(minutes),seconds))
print "\nScript run in: " + TotalTime
Solved! Go to Solution.